POJ1002

#include <iostream>
#include <string>

using namespace std;

int myctoi(const char c);

int a[10000000];

int main()
{
int N;
cin>>N;

string str;
int num;
while(N--)
{
num = 0;
cin>>str;

for(int i = 0; i < str.length(); i++)
{
if(str.at(i) != '-')
num = num * 10 + myctoi(str.at(i));
}

a[num]++;
}

num = 0;
for(int i = 0; i < 10000000; i++)
{
if(a[i] > 1)
{
num = 1;
printf("%03d-%04d %d\n", i/10000 , i%10000 ,a[i]);
}
}
if(num == 0)
printf("No duplicates.\n");
return 0;
}

int myctoi(const char c)
{
if( c == 'A' || c == 'B' || c == 'C') return 2;
if( c == 'D' || c == 'E' || c == 'F') return 3;
if( c == 'G' || c == 'H' || c == 'I') return 4;
if( c == 'J' || c == 'K' || c == 'L') return 5;
if( c == 'M' || c == 'N' || c == 'O') return 6;
if( c == 'P' || c == 'R' || c == 'S') return 7;
if( c == 'T' || c == 'U' || c == 'V') return 8;
if( c == 'W' || c == 'X' || c == 'Y') return 9;
return c - '0';
}

你可能感兴趣的:(C++,c,C#,F#,J#)