Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1002题目求指教。自己测试过了,但是提交后是WA

Posted by Emileee at 2013-12-19 02:03:33
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
using namespace std;

char chToDgt(char ch){
    if (('A'<=ch)&&(ch<='C')) return '2';
    else if (('D'<=ch)&&(ch<='F')) return '3';
    else if (('G'<=ch)&&(ch<='I')) return '4';
    else if (('J'<=ch)&&(ch<='L')) return '5';
    else if (('M'<=ch)&&(ch<='O')) return '6';
    else if ((ch=='P')||(ch=='R')||(ch=='S')) return '7';
    else if (('T'<=ch)&&(ch<='V')) return '8';
    else if (('W'<=ch)&&(ch<='Y'))return '9';
    else {//cout<<"Input error!";
            return 0;
         }
}
int main()
{
    vector<string> svec;
    map<string,int> omap;
    string::size_type ix;
    string s;
    while(cin>>s){
        svec.push_back(s);
    }
    string dgt_letters("ABCDEFGHIJKLMNOPRSTUVWXY0123456789");
    vector<string>::iterator it=svec.begin();
    string cnt=*it++;
    char a=0;
    for(;it!=svec.end();it++){
        ix=0;
        s="";
        string temp=*it;
        while((ix = temp.find_first_of(dgt_letters,ix))!=string::npos){
            if(('0'<=temp[ix])&&(temp[ix]<='9'))
                {
                    s+=temp[ix];
                    ix++;
                }
            else
                {
                    a=chToDgt(temp[ix]);
                    s+=a;
                    ix++;
                }
        }
        ++omap[s];
    }

    for(map<string,int>::iterator map_it=omap.begin();map_it!=omap.end();map_it++){
        if(map_it->second>1)
            cout<<map_it->first.substr(0,3)<<'-'<<map_it->first.substr(3,4)<<' '<<map_it->second<<endl;
    }
    return 0;
}




Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator