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 280516804 at 2009-12-09 20:26:17 on Problem 1002
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100000
long int num[N];
int times[N];
int sum=0;
char cc[N][15];
void kkk(int j),add(long int num),paixu();
int ddd();

int main()
{	
	int i=0,j=0;
	scanf("%d",&i);getchar();
	for (j=0;j<i;j++)
		kkk(j);
	paixu();
	if (ddd())
		printf("No duplicates.\n");
	return 0;
}

void kkk(int j)
{
	int i=0,k=0;
	gets(cc[j]);
	while (i<15)
	{
			 if (cc[j][i]=='A'||cc[j][i]=='B'||cc[j][i]=='C'||cc[j][i]=='a'||cc[j][i]=='b'||cc[j][i]=='c') cc[j][k]='2';
		else if (cc[j][i]=='D'||cc[j][i]=='E'||cc[j][i]=='F'||cc[j][i]=='d'||cc[j][i]=='e'||cc[j][i]=='f') cc[j][k]='3';
		else if (cc[j][i]=='G'||cc[j][i]=='H'||cc[j][i]=='I'||cc[j][i]=='g'||cc[j][i]=='h'||cc[j][i]=='i') cc[j][k]='4';
		else if (cc[j][i]=='J'||cc[j][i]=='K'||cc[j][i]=='L'||cc[j][i]=='j'||cc[j][i]=='k'||cc[j][i]=='l') cc[j][k]='5';
		else if (cc[j][i]=='M'||cc[j][i]=='N'||cc[j][i]=='O'||cc[j][i]=='m'||cc[j][i]=='n'||cc[j][i]=='o') cc[j][k]='6';
		else if (cc[j][i]=='P'||cc[j][i]=='R'||cc[j][i]=='S'||cc[j][i]=='p'||cc[j][i]=='r'||cc[j][i]=='s') cc[j][k]='7';
		else if (cc[j][i]=='T'||cc[j][i]=='U'||cc[j][i]=='V'||cc[j][i]=='t'||cc[j][i]=='u'||cc[j][i]=='v') cc[j][k]='8';
		else if (cc[j][i]=='W'||cc[j][i]=='X'||cc[j][i]=='Y'||cc[j][i]=='w'||cc[j][i]=='x'||cc[j][i]=='y') cc[j][k]='9';
		else if (cc[j][i]<='9'&&cc[j][i]>='0') cc[j][k]=cc[j][i];
		else k--;
		i++,k++;
	}
	cc[j][7]='\0';
	add(atol(cc[j]));
}

void add(long int kk)
{
	int j=0;
	for (j=0;j<sum;j++)
		if (kk==num[j])
		{
			times[j]++;
			return;
		}
	num[sum]=kk,times[sum]=1;
	sum++;
}

int ddd()
{
	int k=1;
	int i=0;
	for (i=0;i<sum;i++)
		if (times[i]>1)
		{	
			printf("%d-%d %d\n",num[i]/10000,num[i]-num[i]/10000*10000,times[i]);
			k=0;
		}
	return k;
}

void paixu()
{
	int i,j,temp1,temp2;
	for (i=1;i<sum;i++)
		for (j=0;j<=sum-i-1;j++)
			if (num[j]>num[j+1])
			{	
				temp1=num[j];
				num[j]=num[j+1];
				num[j+1]=temp1;
				temp2=times[j];
				times[j]=times[j+1];
				times[j+1]=temp2;
			}
}

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