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

## 求大神指点，不知道错在哪里，样例测试没错

Posted by scau201727010609 at 2018-07-18 13:58:53 on Problem 1002
```#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
struct number
{
char s[1000];
int times;
int num;
}present[100000];
char suit[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9'};
char result[1000]={0};
bool cmp(struct number a,struct number b)
{
for(int i=0;i<strlen(a.s);i++)
{
if(a.s[i]!=b.s[i])
return a.s[i]<b.s[i];
}
return a.num<b.num;
}

int main()
{
int n,i,j,k,flag;
char ts[1000]={0};
cin>>n;
fflush(stdin);
k=0;
while(n--)
{
i=0;
gets(ts);
for(j=0;j<strlen(ts);j++)
{
if('A'<=ts[j]&&ts[j]<'Z')
result[i++]=suit[ts[j]-'A'];
else if('0'<=ts[j]&&ts[j]<='9')
result[i++]=ts[j];
if(i==3)
result[i++]='-';
}
//printf("%s\n",result);
flag=0;
for(j=0;j<k;j++)
{
if(strcmp(result,present[j].s)==0)
{
present[j].times++;
flag=1;
break;
}
}
if(!flag)
{
strcpy(present[k].s,result);
present[k].times=1;
present[k].num=k;
k++;
}
}
sort(present,present+k+1,cmp);
for(i=0;i<k;i++)
if(present[i].times>=2)
printf("%s %d\n",present[i].s,present[i].times);

return 0;
}
```

Followed by: