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

高手们帮忙看以下我的1002题为啥老wrong answer! thanks!

Posted by liuzhe1988 at 2008-08-28 17:06:27 on Problem 1002 and last updated at 2008-08-28 17:07:59
#include<stdio.h>
#include<stdlib.h>

int a[100002];

int zhuanhuan(int a[] , int i ,char s[])
{
	int  j = 0 , t = 1000000 ;
	while(t > 0)
	{   if(s[j] == '-') j++;
		else if(s[j]>='A'&&s[j] <='C')
			{ a[i] += t * 2; t /= 10; j++;}
		else if(s[j]>='D'&&s[j] <='F')
			{ a[i] += t * 3; t /= 10; j++;}
		else if(s[j]>='G'&&s[j] <='I')
			{ a[i] += t * 4; t /= 10; j++;}
		else if(s[j]>='J'&&s[j] <='L')
			{ a[i] += t * 5; t /= 10; j++;}
		else if(s[j]>='M'&&s[j] <='O')
			{ a[i] += t * 6; t /= 10; j++;}
		else if(s[j]=='P'||s[j] == 'R'||s[j] =='S')
			{ a[i] += t * 7; t /= 10; j++;}
		else if(s[j]>='T'&&s[j] <='V')
			{ a[i] += t * 8; t /= 10; j++;}
		else if(s[j]>='W'&&s[j] <='Y')
			{ a[i] += t * 9; t /= 10; j++;}
		else if(s[j]<='9'&&s[j]>='0')
			{
			 a[i] += t * (s[j] - '0') ; t /= 10 ;j++;
			}
	}
	return 0;
}

int cmp ( const void *a , const void *b )
{
	return *(int *)a - *(int *)b;
}
int main()
{
	int n , i , j , t = 0 , k ,t1 ,t0;
	char s[50];
	scanf("%d",&n);
	for( i = 0 ; i < n ; i++)
	{
		scanf("%s",&s);
		a[i] = 0;
		zhuanhuan(a,i,s);
	}
	a[n] = 0;
	qsort(a , n ,sizeof(int) , cmp);
	for( i = 0 ; i < n ;  )
	{
	k = 0;
		if(a[i] == a[i + 1]){
			t = 1;
			for(j = i ;j < n ;j++)
			if(a[i] == a[j]) k++;
			else break;
		}
	if(k != 0) {
		t1 = a[i]/10000;
		t0 = a[i]%10000;
		if(t1>=100)
			{
				if(t0<=9999&&t0>=1000)
					printf("%d-%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=999&&t0>=100)
					printf("%d-0%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=99&&t0>10)
					printf("%d-00%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=9&&t0>=0)
					printf("%d-000%d %d\n",a[i]/10000,a[i]%10000,k);
			}

		else if(t1>=10)
			{
				if(t0<=9999&&t0>=1000)
					printf("0%d-%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=999&&t0>=100)
					printf("0%d-0%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=99&&t0>10)
					printf("0%d-00%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=9&&t0>=0)
					printf("0%d-000%d %d\n",a[i]/10000,a[i]%10000,k);
			}

		else if(t1>=0)
			{
				if(t0<=9999&&t0>=1000)
					printf("00%d-%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=999&&t0>=100)
					printf("00%d-0%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=99&&t0>10)
					printf("00%d-00%d %d\n",a[i]/10000,a[i]%10000,k);
				else if(t0<=9&&t0>=0)
					printf("00%d-000%d %d\n",a[i]/10000,a[i]%10000,k);
			}
		}

		if(k == 0) i++;
       	else i = i + k;
	}
	if(t = 0) printf("No duplicates.\n");
	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