TopH Decent Arrays Solution
Solve in C:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,t,f=0,ar[1001],n,a[1001];
while(cin>>n)
{
for(i=0; i<n; i++)
{
cin>>ar[i];
}
for(i=1; i<n; i++)
{
if(ar[i-1]>ar[i])
{
f=1;
break;
}
}
if(f==1)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
f=0;
}
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,t,f=0,ar[1001],n,a[1001];
while(cin>>n)
{
for(i=0; i<n; i++)
{
cin>>ar[i];
}
for(i=1; i<n; i++)
{
if(ar[i-1]>ar[i])
{
f=1;
break;
}
}
if(f==1)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
f=0;
}
}
No comments