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 yx935 at 2018-03-15 18:53:35 on Problem 1002 and last updated at 2018-03-15 19:50:15
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define max 100000

int cmp(const void*a, const void*b);

int main()
{
	int N,temp;
	int a = -1, k =0, j=0, t1 = 0, t2 = 0, t3 = 0, judge=0;
	int num[max];
	for (t3 = 0; t3 < max; t3++) num[t3] = 0;
	scanf("%d", &N);
	for (t2 = 0; t2 <= 8; t2++)
	{
		if (a == N) break;
		temp=getchar();
		if (temp == '-')
		{
			t2--;
			continue;
		}
		else if (temp == 10)
		{
			judge++;
			if (judge == 1)
			{
				a++;
				t2 = 0;
			}
			t2 = 0;
			continue;
		}
		else if (temp >= 48 && temp <= 57) temp -= 48;
		else if (temp >= 65 && temp <= 80) temp = (temp-2) / 3 - 19;
		else if (temp >= 82 && temp <= 89) temp = temp / 3 - 20;
		num[a] += temp*pow(10,(7-t2));
		judge = 0;
	}
	qsort(num, N, sizeof(num[1]), cmp);
	for (t1 = 1; t1 < N; t1++)
	{
		if (num[t1] - num[k])
		{
			if (t1 - k - 1)
			{ 
				printf("%03d-%04d %d\n", num[k]/10000, num[k]%10000, t1 - k);
				j++;
			}
			k = t1;
		}
	}
	if (!j) printf("No duplicates.\n");
	return 0;
}

int cmp(const void*a, const void*b)
{
	return  *(int*)a - *(int*)b;
}

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