1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
using namespace std;
int main()
{
int fibonachi[20]={0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181};
int arr[20];
int sum=0;
int maxdif=0;
for(int i=0;i<20;i++)
{
cin>>arr[i];
}
for(int j=0;j<20;j++)
{
if(arr[j]==fibonachi[j])
{
sum++;
}
if(j==19)
{
break;
}
maxdif=arr[j]-fibonachi[j];
int temp=arr[j+1]-fibonachi[j+1];
if(maxdif<0)
{
maxdif*=-1;
}
if(temp<0)
{
temp*=-1;
}
if(temp>maxdif)
{
temp=arr[j+1];
maxdif=temp;
}
}
cout<<"The quantity of fibonachi nums: "<<sum<<endl;
cout<<"The biggest difference: "<<maxdif<<endl;
system("pause");
return 0;
}
|