Problem Type : Ad Hoc
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int i,j,k,len;
char ch[10000],des[1000],des2[1000];
while(gets(ch))
{
j=0;
if(strcmp(ch,"DONE")==0)
break;
len = strlen(ch);
for(i=0; i<len; i++)
{
if(ch[i]>='a' && ch[i]<='z')
{
des[j]=ch[i]-32;
j++;
}
else if(ch[i]>='A' && ch[i]<='Z')
{
des[j]=ch[i];
j++;
}
}
des[j]='\0';
strcpy(des2,des);
len= strlen(des);
reverse (des,des+len);
if(strcmp(des,des2)==0)
{
printf("You won't be eaten!\n");
}
else
{
printf("Uh oh..\n");
}
memset(ch,'\0',sizeof(ch));
memset(des,'\0',sizeof(des));
memset(des2,'\0',sizeof(des2));
}
}
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int i,j,k,len;
char ch[10000],des[1000],des2[1000];
while(gets(ch))
{
j=0;
if(strcmp(ch,"DONE")==0)
break;
len = strlen(ch);
for(i=0; i<len; i++)
{
if(ch[i]>='a' && ch[i]<='z')
{
des[j]=ch[i]-32;
j++;
}
else if(ch[i]>='A' && ch[i]<='Z')
{
des[j]=ch[i];
j++;
}
}
des[j]='\0';
strcpy(des2,des);
len= strlen(des);
reverse (des,des+len);
if(strcmp(des,des2)==0)
{
printf("You won't be eaten!\n");
}
else
{
printf("Uh oh..\n");
}
memset(ch,'\0',sizeof(ch));
memset(des,'\0',sizeof(des));
memset(des2,'\0',sizeof(des2));
}
}
No comments:
Post a Comment