递归判断数组是否为递增数组
Code
#include <iostream.h>
#include <stdio.h>
bool fun( int a[], int n )
{
if( n==1 )
return true;
if( n==2 )
return a[n-1] >= a[n-2];
return fun( a,n-1) && ( a[n-1] >= a[n-2] );
}
void main()
{
int a[6]={4,8,9,10,11,12};
int count=sizeof(a)/sizeof(a[0]);
cout<<fun(a,count)<<endl;
}
#include <iostream.h>
#include <stdio.h>
bool fun( int a[], int n )
{
if( n==1 )
return true;
if( n==2 )
return a[n-1] >= a[n-2];
return fun( a,n-1) && ( a[n-1] >= a[n-2] );
}
void main()
{
int a[6]={4,8,9,10,11,12};
int count=sizeof(a)/sizeof(a[0]);
cout<<fun(a,count)<<endl;
}