帮忙解决一条c++题目
来源:百度知道 编辑:UC知道 时间:2024/05/22 17:58:23
int find(int a[],int n)
{int s,i;
if(a[1]<a[2]_____;
else s=2;
if(s==1)
{i=2;
while(1<n)
{if (_______________)
{s=3;
break;
}
return s;}
1.s=1
2.a[i++]>=a[i+1]
题目有个地方应该是while(i<n)吧
#include <iostream>
using namespace std;
int find(int a[],int n)
{
if(n<2)
{
cout<<"the number is small"<<endl;
return 0;
}
int s,i;
if(a[1]<a[2])s=1;
else s=2;
if(s==1)
{
i=2;
while(i<n)
{
if(a[i-1]>a[i++])
{
s=3;
break;
}
}
return s;
}
else if(s==2)
{
i=2;
while(i<n)
{
if(a[i-1]<a[i++])