C与C++程序题库

C与C++程序题库

ID:42263924

大小:28.65 KB

页数:15页

时间:2019-09-11

C与C++程序题库_第1页
C与C++程序题库_第2页
C与C++程序题库_第3页
C与C++程序题库_第4页
C与C++程序题库_第5页
资源描述:

《C与C++程序题库》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1085:A+BforInput-OutputPractice(I)题目描述YourtaskistoCalculatea+b.Tooeasy?!Ofcourse!Ispeciallydesignedtheproblemforacmbeginners.Youmusthavefoundthatsomeproblemshavethesametitleswiththisone,yes,alltheseproblemsweredesignedforthesameaim输入Theinputwillconsistofaseriesofpairsofintegersaandb,sep

2、aratedbyaspace,onepairofintegersperline.输出Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.样例输入151020样例输出630提示这是一个求两数之和的题目,输入多对用空格分开的两个数ab,输出a+b的和,每一对数据的和占一行。编写代码时需要注意的是,由于没有指出有多少对输入数据,因此我们可以编写如下代码://C语言#includeintmai

3、n()//把main函数定义成int类型{inta,b;while(scanf("%d%d",&a,&b)!=EOF)//输入结束时,scanf函数返回值为EOF,即没有数据输入时则退出while循环printf("%d",a+b);return0;//返回值为0}//或者C++语言#include//注意头文件的使用方法usingnamespacestd;intmain(){inta,b;while(cin>>a>>b)cout<

4、描述Thefirstlineintegermeansthenumberofinputintegeraandb.YourtaskistoCalculatea+b.输入YourtaskistoCalculatea+b.Thefirstlineintegermeansthenumbersofpairsofinputintegers.输出Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.样例输入2151020

5、样例输出6301087:A+BforInput-OutputPractice(III)题目描述YourtaskistoCalculatea+b.输入Inputcontainsmultipletestcases.Eachtestcasecontainsapairofintegersaandb,onepairofintegersperline.Atestcasecontaining00terminatestheinputandthistestcaseisnottobeprocessed.输出Foreachpairofinputintegersaandbyoushouldo

6、utputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.样例输入15102000样例输出6301088:A+BforInput-OutputPractice(IV)题目描述YourtaskistoCalculatethesumofsomeintegers.输入Inputcontainsmultipletestcases.EachtestcasecontainsaintegerN,andthenNintegersfollowinthesameline.Atestcasestartingwi

7、th0terminatestheinputandthistestcaseisnottobeprocessed.输出Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andwithonelineofoutputforeachlineininput.样例输入412345123450样例输出10151089:A+BforInput-OutputPractice(V)题目描述Yourtaskistocalculatethesumofsomeintegers.输入Inputcontainsa

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。