| ||||||||||
| 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 | |||||||||
请指教,在VC上可以通过,到底哪错了#include<iostream>
#include<string>
using namespace std;
char up(char un)
{
if(un=='A' || un=='B' || un=='C') return '2';
else if(un=='A' || un=='B' || un=='C') return '2';
else if(un=='D' || un=='E' || un=='F') return '3';
else if(un=='G' || un=='H' || un=='I') return '4';
else if(un=='J' || un=='K' || un=='L') return '5';
else if(un=='M' || un=='N' || un=='O') return '6';
else if(un=='P' || un=='R' || un=='S') return '7';
else if(un=='T' || un=='U' || un=='V') return '8';
else if(un=='W' || un=='X' || un=='Y') return '9';
}
string change(string s)
{
for(int i=0;i<s.length();i++)
{
if(s[i]=='-')
{
s.erase(i,1);
i--;
}
s[i]=up(s[i]);
}
s.insert(3,"-");
return s;
}
int main()
{
int N;
string s[100000];
int q[100000];
int t[100000];
int i,j,k;
cin>>N;
for(i=0;i<N;i++)
cin>>s[i];
for(j=0;j<N;j++)
{s[j]=change(s[j]);
}
for(i=0;i<N;i++)
{q[i]=0;
t[i]=1;
}
for(k=0;k<N;k++)
{
if(q[k]==0)
for(i=k+1;i<N;i++)
{
if(s[k]==s[i])
{
q[k]=1;q[i]=1;t[k]++;t[i]--;
}
}
}
bool judge=true;
for(i=0;i<N;i++)
{
if(t[i]==0)
{
judge=false;
break;
}
}
if(judge) cout<<"No duplicates.";
else{
for(i=0;i<N;i++)
if(t[i]>0)
cout<<s[i]<<" "<<t[i]<<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