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

Re:怎么老是Wrong Answer,大侠们帮我看一下吧

Posted by slc14211421 at 2008-09-30 16:28:05 on Problem 1002
In Reply To:怎么老是Wrong Answer,大侠们帮我看一下吧 Posted by:qiqisishijiu at 2008-09-24 10:29:06
> #include <cstdlib>
> #include <iostream>
> #include <map>
> 
> 
> using namespace std;
> 
> void convert(string pn, string& result)
> {
>     result = "";
>     char r[9];
>     int rcount = 0;
>     r[8] = 0;
>     for (int i = 0; i < pn.length(); i++)
>     {
>         char c = pn[i];
>         char nc;
>         switch(c)
>         {
>         case '0':
>         case '1':
>         case '2':
>         case '3':
>         case '4':
>         case '5':
>         case '6':
>         case '7':
>         case '8':
>         case '9':
>             nc = c;
>             break;
>         case 'A':
>         case 'B':
>         case 'C':
>             nc = '2';
>             break;        
>         case 'D':
>         case 'E':
>         case 'F':
>             nc = '3';
>             break; 
>         case 'G':
>         case 'H':
>         case 'I':
>             nc = '4';
>             break;        
>         case 'J':
>         case 'K':
>         case 'L':
>             nc = '5';
>             break; 
>         case 'M':
>         case 'N':
>         case 'O':
>             nc = '6';
>             break;        
>         case 'P':
>         case 'R':
>         case 'S':
>             nc = '7';
>             break; 
>         case 'T':
>         case 'U':
>         case 'V':
>             nc = '8';
>             break;        
>         case 'W':
>         case 'X':
>         case 'Y':
>             nc = '9';
>             break;
>         default:
>             nc = 0;                
>         }
>         if (nc != 0)
>         {
>             r[rcount] = nc;
>             rcount++;
>             if (rcount == 3) {
>                 r[rcount] = '-';
>                 rcount++;
>             }
>             if (rcount == 8)
>                 break;
>         }
>     }
>     result = r;
> }
> 
> int main(int argc, char *argv[])
> {
>     int numPhones = 0;
>     cin >> numPhones;
>     int i = 0;
>     string pn, result;
>     map<string, int> countMap;
>     
>     for (i = 0; i < numPhones; i++)
>     {
>         cin >> pn;
>         convert(pn, result);
>         countMap[result]++;
>     }
>     
>     if (countMap.size() == 0)
>         cout << "No duplicates.";
>     else
>     {
>         map<string,int>::iterator iter;
>         for( iter = countMap.begin(); iter != countMap.end(); iter++ ) {
>             if ((int)(iter->second) > 1)
>                 cout << iter->first << " " << iter->second << endl;
>         }
>     }
>     
>     return 0;
> }


5
4873279
888-4567
967-11-11
310-GINO
F101010

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