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 |
请大家给我看看啊!!!我在VC6.0中结果和答案一样,但是却始终通不过!! #include <iostream> #include <vector> #include <algorithm> #include<iomanip> using namespace std; void main() { int NumOf;//记录输入的个数 int value=1; cin>>NumOf; vector <int> Int; for(int time=0;time<NumOf;time++)//time 循环次数 { char arr[100];//存储号码 int num=0; cin>>arr; while(arr[num]!='\0') { num++; } for(int i=0;i<num;i++) { if(arr[i]=='-') { for(int j=i;j<num;j++) { arr[j]=arr[j+1]; } num--; } } int number=0; int k=0; while(number<num) { switch(arr[number]) { case 'A': case 'B': case 'C': arr[number]='2'; break; case 'D': case 'E': case 'F': arr[number]='3'; break; case 'G': case 'H': case 'I': arr[number]='4'; break; case 'J': case 'K': case 'L': arr[number]='5'; break; case 'M': case 'N': case 'O': arr[number]='6'; break; case 'P': case 'R': case 'S': arr[number]='7'; break; case 'T': case 'U': case 'V': arr[number]='8'; break; case 'W': case 'X': case 'Y': arr[number]='9'; break; default: break; } number++; } Int.push_back(atoi(arr)); } sort(Int.begin(),Int.end()); for(int k=0;k<NumOf;) { int cal=1; for(int l=k+1;l<NumOf&&Int[l]==Int[k];l++) cal++; if(cal>1) { value=0; cout<<setfill('0')<<setw(3)<<Int[k]/10000<<"-"<<setfill('0')<<setw(4)<<Int[k]%10000<<" "<<cal<<endl;// } k=l; } if(value) cout<<"No duplicates."<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator