当前位置: > ACM的 “顺”序列 Time Limit:1000MS Memory Limit:32768K...
题目
ACM的 “顺”序列 Time Limit:1000MS Memory Limit:32768K
Description:
贝贝5岁了.她从一堆数字卡片中选出了4张卡片:5、7、6、8.她摆布了一阵这些卡片后,发现它们可以排成比较顺的序列:5、6、7、8.她同样拿了另4张卡片:5、7、1、2,可是怎么也排不成“顺”的序列.原来,贝贝的所谓“顺”序列是我们所知道的等差数列!贝贝一边拿起一堆数字卡片,一边就在摆布它们,尝试着让它们“顺”起来,可总是有些“顺”,有些不“顺”.这个问题得靠你给她帮忙了,设计一个程序,能够判断对于给定的一堆数字,能“顺”还是不能“顺”.
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
using namespace std;
void bb(int *p,int size) //冒泡排序
{
int i,temp,k=1;
for(int pass=1;pass>n)
{
int i,j;
cin>>m;
for(i=0;ia[i][j];
for(i=0;i

提问时间:2021-12-24

答案
#includeusing namespace std;#include bool isorder(int* a, int m){ sort(a,a+m); int t = a[1]-a[0]; for(int i=3;i>n; for(int i=0;i>m; for(int j=0;j>a[j]; r[i] = m
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.