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 |
【求助】始终是wrong answer ,可是自己调试是没有问题啊#include<iostream> #include<string> #include<vector> #include<map> #include<utility> #include<cctype> using namespace std; int main() { //Sum_num是题目要求的第一个参数 int Sum_num; cin>>Sum_num; //用来存储所有的处理过的TeleNUMber和出现次数 map<string,int> Cumulate; for(int in_temp=0;in_temp!=Sum_num;++in_temp) { //输入各种形式的电话号码 string Telenum; cin>>Telenum; string TempStr(8,'0'); for(string::size_type ix=0,iy=0;ix!=Telenum.size();++ix) { //判断是否为'0'到'9',直接复制到临时string if (isdigit(Telenum[ix])) { //cout<<"OK1"<<endl; TempStr[iy++]=Telenum[ix]; } //判断是否为'A'到'P',计算后复制 else if (Telenum[ix]>='A'&&Telenum[ix]<='P') { //cout<<"OK2"<<endl; TempStr[iy++]=(Telenum[ix]-'A')/3+'2'; } //判断是否为'R'到'P',计算后复制 else if (Telenum[ix]>='R'&&Telenum[ix]<='Y') { //cout<<"OK3"<<endl; TempStr[iy++]=(Telenum[ix]-'Q')/3+'7'; } else //cout<<"Wrong"<<endl ; //在第三个数后加'-' if(iy==3) TempStr[iy++]='-'; } //插入到map中,并自动排序 pair<map<string,int>::iterator,bool> ret=Cumulate.insert(make_pair(TempStr,1)); //如果插入失败(bool=FALSE),出现次数加1 if(!ret.second) ++(ret.first->second); } //打印出出现次数大于1的对象 for(map<string,int>::const_iterator map_it=Cumulate.begin();map_it!=Cumulate.end();++map_it) if(map_it->second>1) cout<<map_it->first<<' '<<map_it->second<<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