电子科大POJ "敲错键盘"
C-sources:
1 #include<stdio.h> 2 #define N 20 3 int main() 4 { 5 int i,j; 6 char RightKeyBoardR[34]={'Q','W','E','R','T','Y','U','I','O','P','[',']', 7 'A','S','D','F','G','H','J','K','L',';','\'','\\', 8 'Z','X','C','V','B','N','M',',','.','/'}; 9 10 char *WrongInput=(char*)malloc(N*sizeof(char)); 11 for(i=0;i<N;i++) 12 WrongInput[i]='\0'; 13 14 gets(WrongInput); 15 16 17 18 int len=strlen(WrongInput); 19 char *MemInput=(char*)malloc((len+1)*sizeof(char)); 20 21 strncpy(MemInput,WrongInput,len+1); 22 23 for(i=0;i<len;i++) 24 for(j=0;j<34;j++) 25 { 26 if(MemInput[i]!=' ') 27 { 28 if(MemInput[i]==RightKeyBoardR[j]) 29 MemInput[i]=RightKeyBoardR[j-1]; 30 } 31 32 } 33 34 35 printf("%s",MemInput); 36 37 return 0; 38 }
作者:vpoet
出处:http://www.cnblogs.com/vpoet/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://www.cnblogs.com/vpoet/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。