标题:uva489 - Hangman Judge
取消只看楼主
Fortitude
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-1-29
 问题点数:0 回复次数:0 
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,请问怎么改进呢?
搜索更多相关主题的帖子: include wrong count 
2012-01-29 12:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360101-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055416 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved