| ||||||||||
| 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 | |||||||||
用stl写的,g++编译,一直报wrong answer,请帮忙看一下#include <iostream>
#include <map>
using namespace std;
char num_map[] = {'2', '2', '2', //A, B, C
'3', '3', '3', //D, E, F
'4', '4', '4', //G, H, I
'5', '5', '5', //J, K, L
'6', '6', '6', //M, N, O
'7', '7', '7', //P, Q, R
'7', '8', '8', //S, T, U
'8', '9', '9', //V, W, X
'9', '9' //Y, Z
};
int main()
{
int num;
cin >> num;
char dialer[1024];
map<int, int> dialer_book;
for (int i = 0; i < num; i++)
{
cin >> dialer;
int number = 0;
for (int j = 0; dialer[j] != '\0'; j++)
{
if (dialer[j] >= 'A' && dialer[j] <= 'Z' &&
dialer[j] != 'Q' && dialer[j] != 'Z')
{
dialer[j] = num_map[dialer[j] - 'A'];
}
if (dialer[j] != '-' && dialer[j] != 'Q' && dialer[j] != 'Z')
{
number = number * 10 + (dialer[j] - '0');
}
}
++dialer_book[number];
}
int found = 0;
map<int, int>::const_iterator mapit = dialer_book.begin();
while (mapit != dialer_book.end())
{
if (mapit->second > 1)
{
cout << mapit->first / 10000 << '-' << mapit->first % 10000 << ' ' << mapit->second << endl;
found = 1;
}
mapit++;
}
if (!found)
{
cout << "No duplicates." << 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