急!很急!!C语言编程题 绝对有加分!

Note:Noarraysarenecessaryforthisproblem.Usescanf,printfasshownbelow.Numbersmayhaveman... Note: No arrays are necessary for this problem. Use scanf, printf as shown below. Numbers may have many digits and may be negative.

You are to write a program to analyse a stream of int values from stdin.A sample input stream might contain (possibly over several lines):

3 2 4 5 7 1 6

which should produce the following output:

(3) (2 4 5 7) (1 6)
Number runs: 3
Length longest run: 4
Smallest element which occurs most times consecutively: 1
Max times it occurs consecutively: 1

The first line of output shows the arguments grouped into "run"s. A run is a subsequence of consecutive elements which is in ascending order, i.e., each element is <= the next. (Runs are used when sorting very large amounts of data. They are merged together to former longer runs until all the data is in one run, i.e., sorted.)

The other output should be self-explanatory. The last line is interesting. If you run the program with the following input:

13 12 12 12 1 1 12 12

the output would be:

(13) (12 12 12) (1 1 12 12)
Number runs: 3
Length longest run: 4
Smallest element which occurs most times consecutively: 12
Max times it occurs consecutively: 3

Start with file a0.c containing:

#include
int main(){
int x;
while ( scanf("%d", &x) == 1 )
printf("%d ", x);
}

and modify it to produce the output requested.
展开
 我来答
前端报错
2010-09-20 · 前端开发技术分享,分析
前端报错
采纳数:1573 获赞数:7027

向TA提问 私信TA
展开全部
/*
Note: No arrays are necessary for this problem. Use scanf, printf as shown below. Numbers may have many digits and may be negative.
注意:这个题目不需要使用数组。用scanf(),printf()就行。数字可能是多位数,也可能是负数。
You are to write a program to analyse a stream of int values from stdin.A sample input stream might contain (possibly over several lines):
写一个程序来分析用户输入的流。下边是一个例(输入也可能占据了多行):
3 2 4 5 7 1 6

which should produce the following output:
程序输出如下:
(3) (2 4 5 7) (1 6)
Number runs: 3
“run”的个数:3
Length longest run: 4
最长的“run”的长度:4
Smallest element which occurs most times consecutively: 1
[*]连续重现的最短元素:1
Max times it occurs consecutively: 1
[*]重现最多的次数:1

The first line of output shows the arguments grouped into "run"s. A run is a subsequence of consecutive elements which is in ascending order, i.e., each element is <= the next.
第一行的输出展示的是编组进多个“run”里的参数。一个“run”是一列按升序排列的元素,即每一个元素都<=下一个。
(Runs are used when sorting very large amounts of data. They are merged together to former longer runs until all the data is in one run, i.e., sorted.)
("run"是在数据量大的时候用来排序的。多个“run”不断的相合并,直到融合成一个“run”。)
The other output should be self-explanatory. The last line is interesting. If you run the program with the following input:
其他的输出就不用再说啥了。最后那行有点儿意思。如果你运行程序,输入以下内容:
13 12 12 12 1 1 12 12

the output would be:
那么,将会输出:
(13) (12 12 12) (1 1 12 12)
Number runs: 3
Length longest run: 4
Smallest element which occurs most times consecutively: 12
Max times it occurs consecutively: 3

Start with file a0.c containing:
从下边的文件a0.c开始:
#include
int main(){
int x;
while ( scanf("%d", &x) == 1 )
printf("%d ", x);
}

and modify it to produce the output requested.
修改完善,来使其按指定要求输出。

注:
1.以上翻译仅供参考;
2.[*]标识处,译者dodo自认为翻译的不够清楚。
*/

#include <stdio.h>
int main(){
int x;
int last;//缓存前一次输入
int switcher=0;//标识括号状态
while ( scanf("%d", &x) == 1 )
{
if( switcher==0 )
{
printf("(");
switcher=1;//没有闭合
}else if( x<last )
{
printf(")");
switcher=0;//闭合
}
printf("%d ", x);
last=x;
}
return 0;
}
一世拼搏
2010-09-20
知道答主
回答量:23
采纳率:0%
帮助的人:0
展开全部
抱歉啊!英语不大好!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式