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 |
求助啊Runtime Error!!#include<iostream> #include<string> #include <algorithm> using namespace std; string convert(string s); int main() { int m; cin>>m; if(m>100000) exit(0); typedef string* stringPtr; stringPtr a; a=new string[m]; int i; for (i=0;i<m;i++) { cin>>a[i]; a[i]=convert(a[i]); } sort(a,a+m); int num,n; for (num=1,i=0; i<m-1; i=n) { while (a[i]==a[i+1]) { num++; n=i+1; i++; } n++; if (num>=2) { string s="-"; cout<<a[n-1].insert(3,s)<<" "<<num<<endl; num=1; } } return 0; } string convert(string s){ string s1; for(int i=0;i<s.length();i++) { switch(s[i]) { case 'A': case 'B': case 'C': case '2': s1+= "2"; break; case 'D': case 'E': case 'F':case '3': s1+= "3"; break; case 'G': case 'H': case 'I': case '4': s1+= "4"; break; case 'J': case 'K': case 'L': case '5': s1+= "5"; break; case 'M': case 'N': case 'O': case '6': s1+= "6"; break; case 'P': case 'R': case 'S': case '7': s1+= "7"; break; case 'T': case 'U': case 'V': case '8': s1+= "8"; break; case 'W': case 'X': case 'Y': case '9': s1+= "9"; break; case '1':s1+= "1";break; case '0':s1+= "0";break; default :break; } } return s1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator