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 1371561216 at 2015-11-02 12:59:48 on Problem 2575
#include <string.h>
#include <stdio.h>
#define YES printf("Jolly\n")
#define NO printf("Not jolly\n")

int abs(int v);
int main(void)
{
	int data[3000];//full use

	int mark[3000];	//use 1~2999

	int i, num, tmp, dif;


	while (1) {
		memset(mark, 0, sizeof(mark));
		scanf("%d", &num);
		getchar();
		if (num == 1) {
			scanf("%d", &tmp);
			tmp = getchar();
			YES;
		}else {
			//if num > 1
			for (i = 0; i <= num -1; i++) {
				scanf("%d", &data[i]);
				tmp = getchar();
			}
			for (i = 0; i <= num -2; ++i) {
				dif = abs(data[i] - data[i+1]);
				if (dif < 1 || dif > num -1 || mark[dif] == 1)//marked befor 
				{
					NO;
					break;
				}else {
					mark[dif] = 1;
				}
			}
			if (i == num -1) {
				YES;
			}
		}
		if (tmp == EOF) {
			return 0;
		}
	}
}
int abs(int v)
{
	return (v >= 0)? v: -v;
}

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