時限: 1000MS | 內存: 131072KB | 64位IO格式: %lld & %llu |
輸入
輸入包含多個測試實例,每一行對應一個字符串,串長最多100字母。
輸出
對每個字符串,輸出它是第幾個,如第一個輸出爲"case1:";如果一個字符串是迴文串,則輸出"yes",否則輸出"no",在yes/no之前用一個空格。
樣例輸入
level abcde noon haha
樣例輸出
case1: yes case2: no case3: yes case4: no
思路:
太水
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s1[105];
char s2[105];
int main()
{
int ca=1;
while(gets(s1)!=NULL)
{
int len=strlen(s1);
memset(s2,'\0',sizeof(s2));
for(int i=len-1,j=0;s1[i]!='\0';i--,j++)
s2[j]=s1[i];
if(strcmp(s1,s2)==0)
printf("case%d: yes\n",ca++);
else
printf("case%d: no\n",ca++);
}
return 0;
}