| ||||||||||
| 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 | |||||||||
为什么我的代码用C++提交通过,用G++就WA,求指点#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include "poj.h"
using namespace std;
const int Max = 10000000;
char dic[28] = "2223334445556667Q77888999Z";
int tels[Max];
int poj1002()
{
int num;
cin >> num;
char s[30];
for(int i = 0; i < num; ++i)
{
scanf("%s",s);
int key = 0;
for (int i = 0; i < strlen(s); ++i)
{
char c = s[i];
if (c != '-' && c != 'Z' && c != 'Q')
{
key = key*10 + (isdigit(c) ? c - '0' : dic[c-'A'] - '0');
}
}
tels[key]++;
}
bool flag = false;
for (int i = 0; i < Max; i++)
{
if (tels[i] > 1)
{
flag = true;
cout << setfill('0') << setw(3) << i/10000;
cout << '-';
cout<< setfill('0') << setw(4) << i%10000;
cout<< " " << tels[i]<<endl;
}
}
if (!flag)
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