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

哪个帮忙看一下

Posted by laohuaa at 2008-07-29 10:02:53 on Problem 1002
我把下面一个人的该了一下不过还是WA
哪个帮忙看一下~~~


#include<iostream>
#include<cstring>
using namespace std;
const int M=100000;
int main()
{
	int i,n,j;
	char c,num[M][9];
	char *pnum[50];
	cin>>n;
	for(i=0;i<n;i++)
	{
		j=0;
		while(cin>>c)
		{
			if(c=='-') continue;
			else if(c>='A'&&c<='C')	num[i][j++]='2';
			else if(c>='D'&&c<='F') num[i][j++]='3';
			else if(c>='G'&&c<='I') num[i][j++]='4';
			else if(c>='J'&&c<='L') num[i][j++]='5';
			else if(c>='M'&&c<='O') num[i][j++]='6';
			else if(c>='P'&&c<='S') num[i][j++]='7';
			else if(c>='T'&&c<='V') num[i][j++]='8';
			else if(c>='W'&&c<='Y') num[i][j++]='9';
			else num[i][j++]=c;
			if(j==3) num[i][j++]='-';
			if(j>7) break;
		}
		pnum[i]=num[i];
		num[i][j]='\0';
	}
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			if(strcmp(pnum[i],pnum[j])>0) swap(pnum[i],pnum[j]);
	int sum,k,flag=1;
	for(i=0;i<n;i++)
	{	
		k=i;
		sum=0;
		for(j=k+1;j<n;j++)
		{
			if(strcmp(pnum[i],pnum[j])==0)
			{
				sum++;
				flag=0;
			}
			else	{i=j-1;break;}

		}
		if(sum)
		{   
			if(k==0)
			{
				for(j=0;j<9;j++)
				cout<<pnum[k][j];
			cout<<sum+1<<endl;
			}
			else if(strcmp(pnum[k],pnum[k-1])!=0)
                       {  
			for(j=0;j<9;j++)
				cout<<pnum[k][j];
			cout<<sum+1<<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