Skip to content

Instantly share code, notes, and snippets.

@ajuanhuang
Created December 5, 2012 12:01
Show Gist options
  • Save ajuanhuang/4215004 to your computer and use it in GitHub Desktop.
Save ajuanhuang/4215004 to your computer and use it in GitHub Desktop.
转变字符
#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
int i,c,k;
while(gets(a))
{
c=strlen(a);
for(i=0;i<c;i++)
{
if(a[i]>='A'&&a[i]<='Y')
printf("%c",a[i]+33);
else if(a[i]=='Z')
printf("a");
else if(a[i]<='c'&&a[i]>='a')
printf("2");
else if(a[i]<='f'&&a[i]>='d')
printf("3");
else if(a[i]>='g'&&a[i]<='i')
printf("4");
else if (a[i]>='j'&&a[i]<='l')
printf("5");
else if(a[i]>='m'&&a[i]<='o')
printf("6");
else if(a[i]>='p'&&a[i]<='s')
printf("7");
else if(a[i]>='t'&&a[i]<='v')
printf("8");
else if(a[i]>='w'&&a[i]<='z')
printf("9");
else
printf("%c",a[i]);
}printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment