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

why ??wa

Posted by zhao999 at 2009-03-06 20:09:34 on Problem 1002
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int t[1000000];
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
void xchang(char *al)
{
	
	if      (*al=='A'||*al=='B'||*al=='C') *al='2';
	else if (*al=='D'||*al=='E'||*al=='F') *al='3';
	else if (*al=='G'||*al=='H'||*al=='I') *al='4';
	else if (*al=='J'||*al=='K'||*al=='L') *al='5';
	else if (*al=='M'||*al=='N'||*al=='O') *al='6';
	else if (*al=='P'||*al=='R'||*al=='S') *al='7';
	else if (*al=='T'||*al=='U'||*al=='V') *al='8';
	else if (*al=='W'||*al=='X'||*al=='Y') *al='9';

}
void print(int d)
{
	cout<<d/10000<<'-'<<d%10000<<" ";
}
int main()
{
	char a[20],ck[8]={'0'};
	int n,i,j,c,mark=0;
	int x,*pItem=NULL,m,k,num=0;
	cin>>n;
	c=n;
	while(n--)
	{
		cin>>a;
		for(i=0,j=0;a[i]!='\0';i++)
			if(a[i]!='-')
			{
				ck[j]=a[i];
				j++;
			}
			for(i=0;i<7;i++)
			xchang(&ck[i]);
			x=atol(ck);
			t[c-n-1]=x;
	}
	qsort(t,c,sizeof(int),compare);
	m=t[0];
	for(i=0;i<c;i++)
	{
		
		if(m==t[i])
		{
			num++;
			continue;
		}
		else if(num>=2)
		{
	
			print(m);
			cout<<num<<endl;
			num=1;
			m=t[i];
			mark=1;
		}
		else
		{
			m=t[i];
			num=1;
		}
	}
	if(mark==0)
		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