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

这也能错,真不知道怎么了?

Posted by 11301655 at 2014-05-31 20:30:44 on Problem 2503 and last updated at 2014-05-31 20:31:18
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define MAX 100010
using namespace std;
struct Node
{
    char en[12];
    char fo[12];
};
Node dic[MAX*100];

int main()
{
    char c;
    char qq[40],ww[40];
    int mark=0;
    int i,j;
    char ss[40];
while(gets(ss)&&ss[0]!='\0')
{
   sscanf(ss,"%s %s",&qq,&ww);
   int len=strlen(ww);
   int sum=0;
   for(i=0;i<len;i++)
      sum+=(ww[i]-'a');
   strcpy(dic[sum].en,qq);
   strcpy(dic[sum].fo,ww);
}
    char str[20];
    while(scanf("%s",str)!=EOF)
    {
        int len=strlen(str);
        int sum=0,i;
        bool flag=0;
        for(i=0;i<len;i++)
            sum+=(str[i]-'a');
        if(!strcmp(str,dic[sum].fo))
        {
            puts(dic[sum].en);
            flag=1;
        }
        if(!flag)
            printf("eh\n");
    }
    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