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

求大神帮忙看一下代码啊,为什么老是WA,disscuss中的能找到的数据基本都测了,输出没有问题啊

Posted by muhaa at 2013-06-26 11:26:07 on Problem 1035
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char words[10001][15];
char matched[51][15];
int len[10001];
int tag[10001];
int t_num;
int w_num;
int m_num;
bool do_check(char str[])
{
        t_num = 0;
        int s_len = strlen(str);
        int same;
        for(int i=0; i<w_num; i++)
        {
                same = 0;
                int j,t;
                if(len[i] == s_len)
                {
                        if(!strcmp(words[i],str))
                        {
                                printf("%s is correct\n",str);
                                return true;
                        }
                        for(j=0, t=0; j<len[i] && t<s_len; j++, t++)
                        {
                                if(words[i][j] != str[t])
                                {
                                        same++;
                                        if(same>1)
                                                break;
                                }
                        }
                        if(same == 1)
                        {
                                tag[t_num] = i;
                                t_num++;
                        }
				}
				   else if(len[i]-s_len == 1)
				 {
                        for(j=0, t=0; j<len[i] && t<s_len;)
                        {
                                if(words[i][j] != str[t])
                                {
                                        same++;
                                        if(same>1)
                                                break;
                                        j++;
                                        continue;
                                }
                                j++; t++;
                        }

                        if(same == 1 || (same == 0 &&j==s_len && t==s_len))
                        {
                                tag[t_num] = i;
                                t_num++;
                        }
                }
                else if(s_len - len[i] == 1)
                {

                        for(j=0, t=0; j<len[i] && t<s_len;)
                        {
                                if(words[i][j] != str[t])
                                {
                                        same++;
                                        if(same>1)
                                                break;
                                        t++;
                                        continue;
                                }
                                j++; t++;
                        }
                        if(same == 1 || (same == 0 &&j==len[i] && t==len[i]))
                        {
                                tag[t_num] = i;
                                t_num++;
                        }
                }
        }
        return false;

}                                                    

int main(int argc, char **argv)
{
	    w_num = 0;
        m_num = 0;
        while(1)
        {
                scanf("%s",words[w_num]);
                if(!strcmp(words[w_num],"#"))
                        break;
                len[w_num]=strlen(words[w_num]);
                w_num++;
        }
        while(1)
        {
                scanf("%s",matched[m_num]);
                if(!strcmp(matched[m_num],"#"))
                        break;
                m_num++;
        }
        for(int i=0; i<m_num; i++)
        {
                if(!do_check(matched[i]))
                {
                        printf("%s:",matched[i]);
						if(t_num ==0)
						{
							printf("\n");
							continue;
						}
                        for(int i=0; i<t_num-1; i++)
					           printf(" %s",words[tag[i]]);
						printf(" %s\n",words[tag[t_num-1]]);
                }
        }
        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