教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 互联网资料 >

C语言编程题目1

来源:网络收集 时间:2026-03-02
导读: (1000). Description Calculate a+b Input Two integer a,b (0 Output Output a+b Sample Input 1 2 Sample Output 3 (1001) Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was buil

(1000).

Description

Calculate a+b

Input

Two integer a,b (0<=a,b<=10)

Output

Output a+b

Sample Input

1 2

Sample Output

3

(1001)

Description

There is a famous railway station in PopPush City. Country there is

incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was

possible to establish only a surface track. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have only one track.

The local tradition is that every train arriving from the direction A continues in the direction B with coaches

reorganized in some way. Assume that the train arriving from the direction A has N <= 1000 coaches numbered in increasing order 1, 2, ..., N. The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a1, a2, ..., aN. Help him and write a program that decides whether it is possible to get the required order of coaches. You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction B it cannot return back to the station.

Input

The input consists of blocks of lines. Each block except the last describes one train and possibly more requirements for its reorganization. In the first line of the block there is the integer N described above. In each of the next lines of the block there is a permutation of 1, 2, ..., N. The last line of the block contains just 0.

The last block consists of just one line containing 0.

Output

The output contains the lines corresponding to the lines with

permutations in the input. A line of the output contains Yes if it is possible to marshal the coaches in the order

required on the corresponding line of the input. Otherwise it contains No. In addition, there is one empty line after the lines corresponding to one block of the input. There is no line in the output corresponding to the last ``null'' block of the input.

Sample Input

5

1 2 3 4 5 5 4 1 2 3 0 6

6 5 4 3 2 1 0 0

Sample Output

Yes

No Yes

(1002)

Description

给你一组数(未排序),请你设计一个程序:求出里面个数最多的数。并输出这个数的长度。

例如:给你的数是:1、 2、 3、 3、 4、 4、 5、 5、 5 、6, 其中只有6组数:1, 2, 3-3, 4-4, 5-5-5 and 6.

最长的是5那组,长度为3。所以输出3。

Input

第一行为整数t((1 ≤ t ≤ 10)),表示有n组测试数据。

每组测试数据包括两行,第一行位数组的长度n (1 ≤ n ≤ 10000)。第二行为n个整数,所有整数Mi的范围都是(1 ≤ Mi ≤ 2^32)

Output

对应每组数据,输出个数最多的数的长度。

Sample Input

1 10

1 2 3 3 4 4 5 5 5 6

Sample Output

3

1003

我们知道,高中会考是按等级来的。 90~100为A; 80~89为B; 70~79为C; 60~69为D; 0~59为E。

编写一个程序,对输入的一个百分制的成绩t,将其转换成对应的等级。 Input

输入数据有多组,每组占一行,由一个整数组成. Output

对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Score is error!”。 Sample Input 56 67 100 123

Sample Output

E D A

Score is error! 答案

#include int main() { int score; while(scanf(\=EOF) {

if(score>=90&&score<=100) printf(\ else if(score>=80&&score<90) printf(\ else if(score>=70&&score<80) printf(\ else if(score>=60&&score<70) printf(\ else if(score>=0&&score<60) printf(\ else printf(\error!\\n\ } return 0; }

1005

已知元素从小到大排列的两个数组x[]和y[],请写出一个程序算出两个数组彼此之间差的绝对值中最小的一个,这叫做数组的距离。 Input

第一行为两个整数m, n(1≤m, n≤1000),分别代表数组f[], g[]的长度。 第二行有m个元素,为数组f[]。 第三行有n个元素,为数组g[]。 Output

数组的最短距离 Sample Input 5 5

1 2 3 4 5 6 7 8 9 10 Sample Output

1

答案:

#include #include int main() { int

m,n,f[1500],g[1500],min,i,j; scanf(\ for(i=0;i

if(min>abs(f[i]-g[j])) min=abs(f[i]-g[j]); printf(\ return 0; } 1035

密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。哇哈哈.

接下来渊子要在密码之上再加一套密码,虽然简单但也安全。

假设渊子原来一个BBS上的密码为zvbo941987,为了方便记忆,他通过一种算法把这个密码变换成

YUANzi1987,这个密码是他的名字和出生年份,怎么忘都忘不了,而且可以明目张胆地放在显眼的地方而不被别人知道真正的密码。

他是这么变换的,大家都知道手机上的字母: 1--1, abc--2, def--3, ghi--4, jkl--5, mno--6, pqrs--7, tuv--8 wxyz--9, 0--0,就这么简单,渊子把密码中出现的小写字母都变成对应的数字,数字和其他的符号都不做变换,声明:密码中没有空格,而密码中出现的大写字母则边成小写之后往后移一位,如:X,先边成小写,再往后移一位,不就是y了嘛,简单吧。记住,z往后移是a哦。 Input

输入包括多个测试数据。输入是一个明文,密码长度不超过100个字符,输入直到文件结尾。

Output

输出渊子真正的密文。

Sample Input

YUANzi1987

Sample Output

zvbo941987 1036

我们在“渊子数”的题目中已经了解了渊子是个什么样的人了,他在大一的时候参加过工商学院的“英语聚乐部”。告诉你个秘密,这个俱乐部是个好地方,不但活动精彩而且有MM。 这不,英语俱乐部举办了一个叫做“英文金曲大赛”的节目。这个节目有好 …… 此处隐藏:2535字,全部文档内容请下载后查看。喜欢就下载吧 ……

C语言编程题目1.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/442345.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)