| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
各位大神求解。。。。为啥结果错误啊。。。?#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int sum[100000];
int i=0;
while(i<n)
{
int t;
for(int j=0;j<7;j++)
{
char c;
cin>>c;
if(c=='-'){j--;continue;}
else if(c=='A'||c=='B'||c=='C'||c=='2') {t=2;}
else if(c=='D'||c=='E'||c=='F'||c=='3') {t=3;}
else if(c=='G'||c=='H'||c=='I'||c=='4') {t=4;}
else if(c=='J'||c=='K'||c=='L'||c=='5') {t=5;}
else if(c=='M'||c=='N'||c=='O'||c=='6') {t=6;}
else if(c=='P'||c=='R'||c=='S'||c=='7') {t=7;}
else if(c=='T'||c=='U'||c=='V'||c=='8') {t=8;}
else if(c=='W'||c=='X'||c=='Y'||c=='9') {t=9;}
else if(c=='0') {t=0;}
else if(c=='1') {t=1;}
sum[i]=sum[i]*10+t;
}
i++;
}
sort(sum,sum+n);
int q=1;
int k=0;
for(i=1;i<n;i++)
{
if(sum[i]==sum[i-1])
{
q++;
continue;
}
if(sum[i]!=sum[i-1]&&q>1)
{printf("%03d-%04d %d\n",sum[i-1]/10000,sum[i-1]%10000,q);q=1;k=1;}
}
if(q>1)
{printf("%03d-%04d %d\n",sum[i-1]/10000,sum[i-1]%10000,q);k=1;}
if(k==0)
cout<<"No duplicates. "<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator