1 /* 2 问题 根据键盘的位置向右错一位输出,其中不会出现QAZ等字符 3 解题思路 建立一个字符串常量,注意回车左边为一个',和存储的时候要写两个否则编译器不识别 4 */ 5 #include<cstdio> 6 #include<cstring> 7 int main() 8 { 9 char list[]="`1234567890-=QWERTYUIOP[]\ASDFGHJKL;'ZXCVBNM,./"; 10 char ch,*p = NULL; 11 while((ch = getchar()) != EOF){ 12 p = strchr(list,ch); 13 if(p != NULL){ 14 printf("%c",*(p-1)); 15 } 16 else 17 printf("%c",ch); 18 } 19 return 0; 20 }
1 #include<cstdio> 2 #include<cstring> 3 #include<map> 4 using namespace std; 5 6 int ishuiwen(char *s); 7 int isjingxiang(char *s); 8 9 int main() 10 { 11 char s[30],h,j; 12 while(scanf("%s",s) != EOF){ 13 h=ishuiwen(s); 14 j=isjingxiang(s); 15 16 if(h){//分清逻辑关系 17 if(j) 18 printf("%s -- is a mirrored palindrome. ",s); 19 else 20 printf("%s -- is a regular palindrome. ",s); 21 } 22 else{ 23 if(j) 24 printf("%s -- is a mirrored string. ",s); 25 else 26 printf("%s -- is not a palindrome. ",s); 27 } 28 } 29 return 0; 30 } 31 32 33 int ishuiwen(char *s){ 34 char str[30]; 35 int len=strlen(s),i,j=0; 36 for(i=len-1;i>=0;i--){ 37 str[j++]=s[i]; 38 } 39 str[j]='