uva489 - Hangman Judge
#include<stdio.h>#include<string.h>
char s[100]={0}, g[100]={0};
int main()
{
int i, n, wrong, count, j, len, flag, right;
scanf("%d",&n);
fflush(stdin);
while(n!=-1)
{
gets(s);
fflush(stdin);
gets(g);
fflush(stdin);
wrong=count=flag=right=0;
len=strlen(s);
printf("Round %d:\n",n);
for(i=0;g[i];i++)
{
count=0;
for(j=0;s[j];j++)
{
if(g[i]==s[j])count++;
}
right+=count;
if(count==0)wrong++;
if(right==len)
{
printf("You win.\n");
flag=1;
break;
}
if(wrong==7)
{
printf("You lose.\n");
flag=1;
break;
}
}
if(flag==0)printf("You chickened out.\n");
memset(s,0,sizeof(s));
memset(g,0,sizeof(g));
scanf("%d",&n);
fflush(stdin);
}
return 0;
}
提交无数次都是TLE,请问怎么改进呢?