No older revisions available
No older revisions available
~cpp JollyJumpler.cpp
¶
~cpp
#include<iostream>
using namespace std;
#include<math.h>
bool seqCheck(int* array,int count);
void main()
{
int input=0;
int count=0;
int oldInput=0;
int total=0;
int array[3000]={0,};
while(cin>>input)
{
count++;
if(count!=1)
array[count-2]=abs(oldInput-input);
oldInput=input;
}
if(seqCheck(array,count))
cout<<"It is Jolly Jumper!\n";
else
cout<<"It isn't Jolly jumper!\n";
}
bool seqCheck(int* array,int count)
{
int checker=0;
for(int i=count-1;i>0;i--)
for(int j=0;j<count-1;j++)
{
if(array[j]==i)
{
checker++;
break;
}
}
if(checker==count-1)
return true;
return false;
}