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

为什么我的代码用C++提交通过,用G++就WA,求指点

Posted by terrier_dog at 2014-11-04 01:30:54 on Problem 1002
#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:
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