C语言编程题目1.docx
- 文档编号:3016164
- 上传时间:2022-11-17
- 格式:DOCX
- 页数:53
- 大小:39.88KB
C语言编程题目1.docx
《C语言编程题目1.docx》由会员分享,可在线阅读,更多相关《C语言编程题目1.docx(53页珍藏版)》请在冰豆网上搜索。
C语言编程题目1
(1000).
Description
Calculatea+b
Input
Twointegera,b(0<=a,b<=10)
Output
Outputa+b
SampleInput
12
SampleOutput
3
(1001)
Description
ThereisafamousrailwaystationinPopPushCity.Countrythereisincrediblyhilly.Thestationwasbuiltinlastcentury.Unfortunately,fundswereextremelylimitedthattime.Itwaspossibletoestablishonlyasurfacetrack.Moreover,itturnedoutthatthestationcouldbeonlyadead-endone(seepicture)andduetolackofavailablespaceitcouldhaveonlyonetrack.
ThelocaltraditionisthateverytrainarrivingfromthedirectionAcontinuesinthedirectionBwithcoachesreorganizedinsomeway.AssumethatthetrainarrivingfromthedirectionAhasN<=1000coachesnumberedinincreasingorder1,2,...,N.ThechieffortrainreorganizationsmustknowwhetheritispossibletomarshalcoachescontinuinginthedirectionBsothattheirorderwillbea1,a2,...,aN.Helphimandwriteaprogramthatdecideswhetheritispossibletogettherequiredorderofcoaches.YoucanassumethatsinglecoachescanbedisconnectedfromthetrainbeforetheyenterthestationandthattheycanmovethemselvesuntiltheyareonthetrackinthedirectionB.Youcanalsosupposethatatanytimetherecanbelocatedasmanycoachesasnecessaryinthestation.ButonceacoachhasenteredthestationitcannotreturntothetrackinthedirectionAandalsoonceithasleftthestationinthedirectionBitcannotreturnbacktothestation.
Input
Theinputconsistsofblocksoflines.Eachblockexceptthelastdescribesonetrainandpossiblymorerequirementsforitsreorganization.InthefirstlineoftheblockthereistheintegerNdescribedabove.Ineachofthenextlinesoftheblockthereisapermutationof1,2,...,N.Thelastlineoftheblockcontainsjust0.
Thelastblockconsistsofjustonelinecontaining0.
Output
Theoutputcontainsthelinescorrespondingtothelineswithpermutationsintheinput.AlineoftheoutputcontainsYesifitispossibletomarshalthecoachesintheorderrequiredonthecorrespondinglineoftheinput.OtherwiseitcontainsNo.Inaddition,thereisoneemptylineafterthelinescorrespondingtooneblockoftheinput.Thereisnolineintheoutputcorrespondingtothelast``null''blockoftheinput.
SampleInput
5
12345
54123
0
6
654321
0
0
SampleOutput
Yes
No
Yes
(1002)
Description
给你一组数(未排序),请你设计一个程序:
求出里面个数最多的数。
并输出这个数的长度。
例如:
给你的数是:
1、2、3、3、4、4、5、5、5、6,其中只有6组数:
1,2,3-3,4-4,5-5-5and6.
最长的是5那组,长度为3。
所以输出3。
Input
第一行为整数t((1≤t≤10)),表示有n组测试数据。
每组测试数据包括两行,第一行位数组的长度n(1≤n≤10000)。
第二行为n个整数,所有整数Mi的范围都是(1≤Mi≤2^32)
Output
对应每组数据,输出个数最多的数的长度。
SampleInput
1
10
1233445556
SampleOutput
3
1003
我们知道,高中会考是按等级来的。
90~100为A;
80~89为B;
70~79为C;
60~69为D;
0~59为E。
编写一个程序,对输入的一个百分制的成绩t,将其转换成对应的等级。
Input
输入数据有多组,每组占一行,由一个整数组成.
Output
对于每组输入数据,输出一行。
如果输入数据不在0~100范围内,请输出一行:
“Scoreiserror!
”。
SampleInput
56
67
100
123
SampleOutput
E
D
A
Scoreiserror!
答案
#include
intmain()
{
intscore;
while(scanf("%d",&score)!
=EOF)
{
if(score>=90&&score<=100)
printf("A\n");
elseif(score>=80&&score<90)
printf("B\n");
elseif(score>=70&&score<80)
printf("C\n");
elseif(score>=60&&score<70)
printf("D\n");
elseif(score>=0&&score<60)
printf("E\n");
else
printf("Scoreiserror!
\n");
}
return0;
}
1005
已知元素从小到大排列的两个数组x[]和y[],请写出一个程序算出两个数组彼此之间差的绝对值中最小的一个,这叫做数组的距离。
Input
第一行为两个整数m,n(1≤m,n≤1000),分别代表数组f[],g[]的长度。
第二行有m个元素,为数组f[]。
第三行有n个元素,为数组g[]。
Output
数组的最短距离
SampleInput
55
12345
678910
SampleOutput
1
答案:
#include
#include
intmain()
{
intm,n,f[1500],g[1500],min,i,j;
scanf("%d%d",&m,&n);
for(i=0;i scanf("%d",&f[i]); for(j=0;j scanf("%d",&g[j]); min=abs(f[0]-g[0]); for(i=0;i for(j=0;j if(min>abs(f[i]-g[j])) min=abs(f[i]-g[j]); printf("%d\n",min); return0; } 1035 密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。 哇哈哈. 接下来渊子要在密码之上再加一套密码,虽然简单但也安全。 假设渊子原来一个BBS上的密码为zvbo941987,为了方便记忆,他通过一种算法把这个密码变换成YUANzi1987,这个密码是他的名字和出生年份,怎么忘都忘不了,而且可以明目张胆地放在显眼的地方而不被别人知道真正的密码。 他是这么变换的,大家都知道手机上的字母: 1--1,abc--2,def--3,ghi--4,jkl--5,mno--6,pqrs--7,tuv--8wxyz--9,0--0,就这么简单,渊子把密码中出现的小写字母都变成对应的数字,数字和其他的符号都不做变换,声明: 密码中没有空格,而密码中出现的大写字母则边成小写之后往后移一位,如: X,先边成小写,再往后移一位,不就是y了嘛,简单吧。 记住,z往后移是a哦。 Input 输入包括多个测试数据。 输入是一个明文,密码长度不超过100个字符,输入直到文件结尾。 Output 输出渊子真正的密文。 SampleInput YUANzi1987 SampleOutput zvbo941987 1036 我们在“渊子数”的题目中已经了解了渊子是个什么样的人了,他在大一的时候参加过工商学院的“英语聚乐部”。 告诉你个秘密,这个俱乐部是个好地方,不但活动精彩而且有MM。 这不,英语俱乐部举办了一个叫做“英文金曲大赛”的节目。 这个节目有好多人参加,这不,成绩出来了,渊子当是很勇敢,自告奋勇接下了算出大家的总得分的任务。 当时有7个评委,每个评委都要给选手打分,现在要求去掉一个最高分和去掉一个最低分,再算出平均分。 结果精确到小数点后两位。 Input 测试数据包括多个实例。 每组数据包括7个实数,代表评委们对该选手的评分。 紧接着是选手的名字,名字的长度不超过30个字符。 输入直到文件结束。 Out
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 编程 题目