C++程序:“顺”序列

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:05:00
Input:
输入中第一行为一个整数n(1≤n≤10),描述后面一共有n组卡片,每组卡片的第一个数m(1≤m≤100),表示后面会出现m张卡片。
Output:
针对每组卡片,判断是否能构成“顺”序列。如果能构成“顺”序列,则输出“yes”,否则就输出“no”。每个结果应分别不同行显示。
Sample Input:
2
4 5 7 6 8
8 1 7 3 2 8 12 78 3
Sample Output:
yes
no

#include<iostream.h>
int main()
{
int m;
cout<<"输入一个整数"<<endl;
cin>>m;
int n=m;
int a[n];
for(n=0;n<=m-1;n++)
{cout<<"输入各行头一个数"<<endl;
cin>>a[n];}
int f=a[0],b=a[1];
int r[f],c,k[b],e;
for(c=0;c<=f-1;c++)
{cout<<"输入行的数字"<<endl;
cin>>r[c];}
for(c=0;c<=f-1;c++)
{if(r[c]<r[c+1])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;}
for(e=0;e<=b-1;e++)
{cout<<"输入行的数字"<<endl;
cin>>k[e];}
for(e=0;e<=b-1;e++)
{if(k[e]<k[e+1])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;}
system("PAUSE");
return 0;
} 这个只能输入2行