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

实在搞不懂为什么,一直都是WA。单机都没问题。。。该改的地方都该过了。。。求大神帮忙

Posted by Doneker at 2016-09-25 03:21:44 on Problem 1002
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int Num, i,flag=1,j,k=0,ValidType=0;string temp;cin >> Num;
	string *Tel = new string[Num]; string *Tel2 = new string[Num];
	string Tel3[300];int count[300];
	for (i = 0; i<Num; i++) cin >> *(Tel + i);
	for (i = 0; i < Num; i++){temp = *(Tel + i);
		for (j = 0; j < temp.size(); j++){
			switch (temp[j]){
			case 'A':case 'B':case 'C':*(Tel2 + i) = *(Tel2 + i) + '2'; break;
			case 'D':case 'E':case 'F':*(Tel2 + i) = *(Tel2 + i) + '3'; break;
			case 'G':case 'H':case 'I':*(Tel2 + i) = *(Tel2 + i) + '4'; break;
			case 'J':case 'K':case 'L':*(Tel2 + i) = *(Tel2 + i) + '5'; break;
			case 'M':case 'N':case 'O':*(Tel2 + i) = *(Tel2 + i) + '6'; break;
			case 'P':case 'R':case 'S':*(Tel2 + i) = *(Tel2 + i) + '7'; break;
			case 'T':case 'U':case 'V':*(Tel2 + i) = *(Tel2 + i) + '8'; break;
			case 'W':case 'X':case 'Y':*(Tel2 + i) = *(Tel2 + i) + '9'; break;
			case '-':break;default:*(Tel2 + i) = *(Tel2 + i) + temp[j]; break;}}}
	sort(Tel2, Tel2 + Num);

	for (i = 0; i < Num; i++){
		if ((Tel2 + i)->size() == 7){
			if (k > 0){flag = 1;
				for (j = 0; j < k; j++){
					if (*(Tel3 + j) == *(Tel2 + i)) {count[j]++;flag = 0;break;}}
				if(flag) {k++;Tel3[k-1] = *(Tel2 + i);count[k - 1] = 1;}}
			else { Tel3[k] = *(Tel2 + i); k++; count[k-1] = 1; }}}

	ValidType = k;string ch; flag = 0;
	for (i = 0; i < ValidType; i++)if (count[i] != 1) { flag = 1; break; }
	if (!flag){cout << "No duplicates."<<endl ;return 1;}
	for (i = 0; i < ValidType; i++){
		if (count[i] != 1){
			ch = Tel3[i];
			for (k = 0; k < 3; k++) cout << ch[k];cout << "-";
			for (k = 3; k < 7; k++)cout << ch[k];
			cout << " " << count[i] << endl;}}
	return 1;}

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