2 条题解
-
0
Infinity_ LV 8 @ 8 个月前
-
-25 年前@
- 1
信息
- 难度
- 6
- 分类
- (无)
- 标签
- 递交数
- 953
- 已通过
- 282
- 通过率
- 30%
- 被复制
- 8
- 上传者
#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;
}
#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;
}