Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:测试数据都可以通过 但还是WS 求大神指点

Posted by MrGaozhong at 2018-09-09 09:17:31 on Problem 1035
In Reply To:测试数据都可以通过 但还是WS 求大神指点 Posted by:hanjiangtao at 2015-01-11 22:07:13
> #include<stdio.h>
> #include<string.h>
> char a[10010][20];
> 
> int main()
> {
>     char b[20], c[15];
>     int k, r, ss;
>     memset(a, 0, sizeof(a));
>     k = 0;
>     for(int i = 1; i < 10001; i++)
>     {
>         scanf("%s",c);
>         k++;
>         if(c[0] == '#')
>             break;
>         else
>             strcpy(a[i], c);
> 
>     }
>     //完成输入
>     scanf("%s",b);
>     while(b[0] != '#')
>     {
>         r = 0;
>         for(int i = 1; i <= k; i++)
>         {
>             if(!strcmp(b, a[i]))
>             {
>                 printf("%s is correct\n",b);
>                 r = 1;
>                 break;
>             }
>         }
>         //完全正确的比较
> 
>         if(r != 1)
>         {
> 
>             printf("%s:",b);
> 
> 
>             for(int i = 1; i <= k; i++)
>             {
>                 ss = 0;
>                 if(strlen(b) == (strlen(a[i]) - 1) )
>                 {
>                     for(int j = 0 , m = 0; j <= strlen(b); j++)
>                     {
>                         if(b[m] == a[i][j])
>                             m++;
>                         else
>                             ss++;
>                     }
>                 }
>                 if(ss == 1)
>                     printf(" %s",a[i]);
> 
>                 //少一个的做法
> 
> 
>                 ss = 0;
>                 if(strlen(b) == (strlen(a[i]) + 1) )
>                 {
>                     for(int j = 0 , m = 0; m <= strlen(b); m++)
>                     {
>                         if(b[m] == a[i][j])
>                             j++;
>                         else
>                             ss++;
>                     }
>                 }
>                 if(ss == 1)
>                     printf(" %s",a[i]);
> 
>                 //加上一个的做法
> 
> 
> 
>                 ss = 0;
>                 if(strlen(b) == strlen(a[i])   )
>                 {
>                     for(int j = 0 , m = 0; m <= strlen(b); m++, j++)
>                     {
>                         if(b[m] != a[i][j])
>                             ss++;
>                     }
>                 }
>                 if(ss == 1)
>                     printf(" %s",a[i]);
>             }
>             //改一个的做法
>             printf("\n");
> 
>         }
> 
> 
>         scanf("%s",b);
>     }
> 
> 
>     return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator