欢迎来到天天文库
浏览记录
ID:42263924
大小:28.65 KB
页数:15页
时间:2019-09-11
《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.样例输入21510205、样例输出6301087:A+BforInput-OutputPractice(III)题目描述YourtaskistoCalculatea+b.输入Inputcontainsmultipletestcases.Eachtestcasecontainsapairofintegersaandb,onepairofintegersperline.Atestcasecontaining00terminatestheinputandthistestcaseisnottobeprocessed.输出Foreachpairofinputintegersaandbyoushouldo6、utputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.样例输入15102000样例输出6301088:A+BforInput-OutputPractice(IV)题目描述YourtaskistoCalculatethesumofsomeintegers.输入Inputcontainsmultipletestcases.EachtestcasecontainsaintegerN,andthenNintegersfollowinthesameline.Atestcasestartingwi7、th0terminatestheinputandthistestcaseisnottobeprocessed.输出Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andwithonelineofoutputforeachlineininput.样例输入412345123450样例输出10151089:A+BforInput-OutputPractice(V)题目描述Yourtaskistocalculatethesumofsomeintegers.输入Inputcontainsa
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
此文档下载收益归作者所有