2 条题解

  • 0
    @ 2024-08-23 18:37:51
    #include<bits/stdc++.h>
    using namespace std;
    int a[10010];
    int main(){
        ios::sync_with_stdio(false);
        int n, m, cnt1 = 0, cnt2 = 0;
        cin >> n >> m;
        a[n+1] = INT_MIN;
        for(int i = 1; i <= n; i++)cin >> a[i];
        for(int i = 1; i <= n; i++){
            if(a[i] > a[i+1])cnt1++;
        }
        a[m+1] = INT_MIN;
        for(int i = 1; i <= m; i++)cin >> a[i];
        for(int i = 1; i <= m; i++){
            if(a[i] > a[i+1])cnt2++;
        }
        cout << cnt1 << ' ' << cnt2;
        return 0;
    }
    
  • -2
    #include<iostream>
    using namespace std;
    class Array
    {
    private:
        int n;
        int size;
        int *a;
        int flag;
    public:
        Array(int set_n)
        {
            n=set_n;
            size=n*2;
            a=new int[size];
            flag=0;
        }
    
        void set_array()
        {
            for(int i=0;i<n;i++)
                cin>>a[i];
        }
    
        void judge()
        {
            for(int i=0;i<n-1;i++)
            {
                if(a[i]>a[i+1])
                    flag++;
            }
            cout<<flag+1;
        }
    
    };
    
    int main()
    {
        int n1,n2;
        cin>>n1>>n2;
        Array arr1(n1);
        Array arr2(n2);
        arr1.set_array();
        arr2.set_array();
        arr1.judge();
        cout<<" ";
        arr2.judge();
        cout<<endl;
    
        system("pause");
        return 0;
    }
    
  • 1

A9-6 数组中增序子序列的个数

信息

难度
6
分类
(无)
标签
递交数
782
已通过
232
通过率
30%
被复制
8
上传者