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 FengSan at 2011-12-17 17:11:11 on Problem 2575
#include<stdio.h>
#include<stdlib.h>
int num[3100];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF&&n<3000)
	{
		if(n==1)                    //n=1另外处理
		{
			scanf("%d",&num[0]);
			printf("Jolly\n");
		}
		else
		{
			int i;                        //输入
			for( i=0;i<n;i++) scanf("%d",&num[i]);
			for( i=0;i<n-1;i++)//int
			{
				num[i]=abs(num[i+1]-num[i]);
			}
			
			for(i=0;i<n-1;i++)          //排序
			{	
				for(int j=i;j<n-1;j++)
				{
					if(num[i]>num[j])
					{
						int temp=num[i];
						num[i]=num[j];
						num[j]=temp;
					}
				}
			}
		
			int jolly=1;                //判断和输出
			for( i=0;i<n-1;i++)//int
				if(num[i]!=i+1) jolly=0;
			if(jolly==1) printf("Jolly\n");
			else printf("Not jolly\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