题解 | #Is Sorted#

Is Sorted

https://ac.nowcoder.com/acm/problem/14322

题目描述

A sequence contains n integers, can you make a judgment of whether the sequence is strictly increasing.

输入描述:

There are multiple test cases. The first line is an positive integer indicating the number of test cases.
For each test case:
Line 1. A positive integer n, standing for the number of elements in the sequence.
Line 2. This line contains n integers, a1, a2, ..., an(2<=n<=100, 0<=ai<=1000) separated by space.

输出描述:

For each test case, output one line. If the sequence is strictly increasing, print "Yes", else print "No".

数组中,若出现“后一个数大于等于前一个数”,则该数组非递增
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int n,sum;
    while(t--)
    {
        vector<int> a;
        bool flag=true;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>sum;
            a.push_back(sum);
        }
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>=a[i+1]) 
            {
                flag=false;
                cout<<"No"<<endl;
                break;
            }
        }
        if(flag) cout<<"Yes"<<endl;
    }
    return 0;
}


全部评论

相关推荐

头像
11-03 16:48
已编辑
百度_高级研发工程师
事实是检验真理的唯一标准。&nbsp;无论我们怎么去说,去讲述,去证明,都抵不过一个offer来得实在,无论我们怎么去复现求职中的摸爬滚打、扒皮抽筋、狼狈不堪,都抵不过你在简历写上大厂的名字(外包不算)。&nbsp;所以在我求职期间,我什么话都不说,什么话都不讲,因为没有意义,虽然我总讲过程才是意义,但只有当你上岸的那一刻,你才有资格回想在水里的挣扎,只有等你出了山,你才知道山的全貌。&nbsp;我为什么一定要离开华为OD,难道它不稳定吗,不能赚钱吗。为了证明自己,那肯定有的。其实更多的是印证我的认知是否真的正确。&nbsp;(给不了解我的人交代一下背景,在下双非一本,gap一年,华为OD外包,摸爬滚打4个月,艰难上岸百度正编)一、...
先锋战士:说得很真诚。鄙视链自古有之,学历,家庭背景,财富,权利。从小有之,小学羡慕那些当班委的,中学羡慕那些学生会的,高中羡慕尖子班拿教学金的,大学羡慕高绩点,毕业了羡慕进大厂的。工作了,又羡慕高职级的,再后来又羡慕别人早早结婚的。我想表达的观点很简单,无论是华为od还是百度,都是经历,没有孰高孰低,为了抵达下一个风景,总会付出更多东西,但不就是人生吗?正如登山,每个阶段的山,都要想办法攀登,在博主的文字中,见到了坚持和积极寻找问题解决办法的心态
学历对求职的影响
点赞 评论 收藏
分享
__Offer__:认识的室友啥也不回细节,线下面联想大模型一次通关我给我干不回了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务