Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么都不知道哪里错了,求指教#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator