Skip to content

Instantly share code, notes, and snippets.

@yuikns
Created August 3, 2014 04:47
Show Gist options
  • Save yuikns/7492931c34910ff05838 to your computer and use it in GitHub Desktop.
Save yuikns/7492931c34910ff05838 to your computer and use it in GitHub Desktop.
// for http://fun.coolshell.cn/unix.html
#include <stdio.h>
#include <string.h>
int main()
{
char * seq1 = "pvwdgazxubqfsnrhocitlkeymj";
char seq[32] = "";
for(int i = 0 ; i < strlen(seq1) ; i ++)
{
seq[seq1[i] - 'a' ] = 'a' + i;
}
seq[27] = '0';
printf("%s\n",seq);
char buff[1024];
while((scanf("%s",buff)) != EOF)
{
for(int i = 0 ; i < strlen(buff) ; i ++)
{
//printf("[%c]",buff[i]);
if(buff[i] >= 'a' && buff[i] <= 'z')
{
putchar(seq[buff[i] - 'a']);
}else if(buff[i] >= 'A' && buff[i] <= 'Z')
{
putchar(seq[buff[i] - 'A'] - 32);
}else
{
putchar(buff[i]);
}
}
putchar(' ');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment