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

为什么我的代码WA？

Posted by nullptr at 2017-02-01 16:29:41 on Problem 1002
```#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int nums[100000];
char s[16],*p;
int n,t,sum,i,ct=1;
bool b=false;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%s",s);
sum=0;
for (p=s;*p;p++)
{
t=0;
if (*p>='0'&&*p<='9')
t=*p-'0';
else if (*p>='A'&&*p<'Z')
{
if (*p<'Q')
t=(*p-'A')/3+2;
else
t=(*p-'A'-1)/3+2;
}
else
continue;
sum=sum*10+t;
}
nums[i]=sum;
}
std::sort(nums,nums+n);
/*
for (i=1;i<n;i++)
{
if (nums[i]==nums[i-1])
ct++;
else
{
if (ct>1)
{
printf("%03d-%04d %d\n",nums[i-1]/10000,nums[i-1]%10000,ct);
b=true;
}
ct=1;
}
}
*/
for (i=1;;)
{
ct=1;
while (nums[i]==nums[i-1]&&i<n)
{
ct++;
i++;
}
if (ct>1)
{
printf("%03d-%04d %d\n",nums[i-1]/10000,nums[i-1]%10000,ct);
b=true;
}
i++;
if (i>=n)
break;
}
if (!b)
printf("No duplicates.\n");
}```

Followed by: