uva 621
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char v[10000] ; 6 int n ; 7 scanf("%d",&n); 8 while( n--) 9 { int i = 0 ; 10 memset(v , 'z',sizeof(v)); 11 scanf("%s",v); 12 i = strlen(v);v[i]='z';i--; 13 14 if( (v[0]=='1' || v[0]=='4') && v[2]== 'z') 15 {printf("+\n");continue;} 16 if(v[0] == '7' && v[1] =='8' && v[2]=='z') 17 {printf("+\n");continue;} 18 19 if(v[i] == '4' && v[0]== '9'){printf("*\n") ;continue;} 20 if(v[i]== '5' && v[i-1]== '3'){printf("-\n"); continue;} 21 if(v[0]=='1' && v[1]== '9' && v[2]== '0'){printf("?\n"); continue;} 22 } 23 return 0 ; 24 }
注意:别忘了字符串后面会加上'\0'
例如 输入78时 v[2] == '\0'