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 00448175 at 2005-03-22 22:31:13 on Problem 1002
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
int compare(const void* a,const void* b)
{
	return strcmp((char*)a,(char*)b);
}


void main()
{
	int k;
	cin>>k;
	tele=new char [k][16];
	char (*tele2)[16];
	tele2=new char [k][16];

	
	for(int i=0;i<k;i++)
	{
		cin>>tele[i];
		
		for(int j=0,n=0;n<7;j++)
		{
			if(tele[i][j]=='-')
				continue;
			if(tele[i][j]>57)
			{
				if(tele[i][j]<81)
					tele2[i][n]=char(int((tele[i][j]-'A'+1)/3.1)+50);
				else
					tele2[i][n]=char(int((tele[i][j]-'A')/3.1)+50);
				n++;
				continue;
			}

			tele2[i][n]=tele[i][j];
			n++;
		}
		tele2[i][7]='\0';
	}
	qsort(tele2,k,sizeof(tele2[0]),compare);
	
	int *num;
	num=new int [k];
	for(i=0;i<k;i++)
		num[i]=1;
	int j=1;
	for( i=0;i<k;j=1)
	{
		while(!(strcmp(tele2[i],tele2[i+j])))
		{
			num[i]++;
			j++;
		}
		i+=j;
	}
	int e=0;
	for(i=0;i<k;i++)
	{	
		if(num[i]!=1)
		{
			for(int m=0;m<3;m+][m];
			cout<<'-+)
				cout<<tele2[i';
			for(m=3;m<7;m++)
				cout<<tele2[i][m];
			cout<<" "<<num[i]<<endl;
			e=1;
		}
	}
	
	if(!e)
		cout<<"No duplicates."<<endl;
	delete[]tele;
	delete[]tele2;
}
	
	
	


	

		

	
	

					


		 

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