Solution of Problem-C- Jolly Jumpers

#include<stdio.h>
int main()
{
int n,a[3000];

do
{
int z=0,j=1;
scanf(“%d”,&n);
for(int i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}

for(int i=0;i<n;i++)
{
if(a[i]<a[i+1])
{
if((a[i+1]-a[i])==(n-j))
z++;

else
break;

}

else
{
if((a[i]-a[i+1])==(n-j))
z++;

else
break;
}

j++;
}
if(z==(n-1))
printf(“Jolly”);

else
printf(“Not jolly”);
}
while(!feof(stdin));
}

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: