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啊!!000-0000都试过了,没有问题的…… 不胜感激!!!!!!!!!!!!!!

Posted by 90305103 at 2003-11-26 16:53:00 on Problem 1002
#include <stdio.h>
#include <math.h>
#include <search.h>

int cmp(const void*a, const void*b){
	int i = *(int*)a, j=*(int*)b;
	return ((i>j)?1:(i<j)?-1:0);
} 

int mt(int x){
	int x1,out;
	out=1;
	for (x1=1;x1<=x;x1++){
		out=out*10;
	}
	return(out);
}

void main(){
	int n,i,k,u,t;
	int i0,k0;
	char tel[20];
	int a[100200],r[100200];
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		u=0;k=-1;
		scanf("%s",tel);
		a[i]=0;
		do{
			u=u+1;
			k=k+1;
			do{
				if (tel[k]=='-') k=k+1;
			}
			while (tel[k]=='-');
			if (tel[k]=='A'||tel[k]=='B'||tel[k]=='C') t=2;
			else if (tel[k]=='D'||tel[k]=='E'||tel[k]=='F') t=3;
			else if (tel[k]=='G'||tel[k]=='H'||tel[k]=='I') t=4;
			else if (tel[k]=='J'||tel[k]=='K'||tel[k]=='L') t=5;
			else if (tel[k]=='M'||tel[k]=='N'||tel[k]=='O') t=6;
			else if (tel[k]=='P'||tel[k]=='R'||tel[k]=='S') t=7;
			else if (tel[k]=='T'||tel[k]=='U'||tel[k]=='V') t=8;
			else if (tel[k]=='W'||tel[k]=='X'||tel[k]=='Y') t=9;
		
			else if (tel[k]=='a'||tel[k]=='b'||tel[k]=='c') t=2;
			else if (tel[k]=='d'||tel[k]=='e'||tel[k]=='f') t=3;
			else if (tel[k]=='g'||tel[k]=='h'||tel[k]=='i') t=4;
			else if (tel[k]=='j'||tel[k]=='k'||tel[k]=='l') t=5;
			else if (tel[k]=='m'||tel[k]=='n'||tel[k]=='o') t=6;
			else if (tel[k]=='p'||tel[k]=='r'||tel[k]=='s') t=7;
			else if (tel[k]=='t'||tel[k]=='u'||tel[k]=='v') t=8;
			else if (tel[k]=='w'||tel[k]=='x'||tel[k]=='y') t=9;
			else if (tel[k]=='1') t=1;
			else if (tel[k]=='2') t=2;
			else if (tel[k]=='3') t=3;
			else if (tel[k]=='4') t=4;
			else if (tel[k]=='5') t=5;
			else if (tel[k]=='6') t=6;
			else if (tel[k]=='7') t=7;
			else if (tel[k]=='8') t=8;
			else if (tel[k]=='9') t=9;
			else if (tel[k]=='0') t=0;
			a[i]=a[i]+(t*(mt(7-u)));
		}
			while (u<7);
	}
	qsort(a,n+1,sizeof(a[0]),cmp);  /*对n个电话排序*/
	k0=0;
	for (i0=1;i0<=n;i0++){
		if (a[i0]==a[i0-1]&&a[i0]==a[i0+1]) r[k0]=r[k0]+1;
		else if (a[i0]==a[i0-1]&&a[i0]!=a[i0+1]){
			r[k0]=r[k0]+1;
			for(i=7;i>=1;i--){
				if (i==4) printf("-");
				printf("%d",a[i0]/(mt(i-1)));
				a[i0]=a[i0]-(a[i0]/(mt(i-1)))*mt(i-1);
			}
			printf(" %d\n",r[k0]);
		}
	    else{
			if (a[i0]==a[i0+1]){
				k0=k0+1; r[k0]=1;
			}
		}
	}

	if (k0==0) printf("No duplicates.\n");
}

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