不是VIP会员,不能显示答案

题目解答

题目:
#include<iostream>

#include<vector>

int cmp(int x, int y)

{

if(x>y)return 1;

else if(x==y)return 0;

else return -1;

}

int main()

{

int n;

std::cin>>n;

std::vector<int> a(n+5);

for(int i=1; i<=n; i++)

std::cin>>a[i];

int now=-1;

for(int i=2; i<=n; i++)

{

int c=cmp (a[i-1],a[i]);

if (c>=now) now=c;

else

{

std::cout<<"NO"<<std::endl;

return 0;

}

}

std::cout<<"YES" <<std::endl;

return 0;

}


判断题

1) 如果输入满足 1≤n≤100, 1≤a[i]≤1000 (下同),则程序只会输出YES或NO两种结果。( )

2) cmp函数的作用是比较两个数x,y的大小,如果x较大返回-1,如果y较大返回1,如果一样大返回0。( )

3) 该程序的时间复杂度为0(n)。 ( )


选择题

4) 输入为( ) 时输出为YES。

5) 如果将第24行去掉,这时输出中最多包含( )个大写字母 0。




考点:
分析:
解答:
评论:
老师: