部分ACM题目与问题详解.doc
《部分ACM题目与问题详解.doc》由会员分享,可在线阅读,更多相关《部分ACM题目与问题详解.doc(91页珍藏版)》请在课桌文档上搜索。
1、word1001 Sum Problem21089 A+B for Input-Output Practice (I)41090 A+B for Input-Output Practice (II)61091 A+B for Input-Output Practice (III)81092 A+B for Input-Output Practice (IV)91093 A+B for Input-Output Practice (V)111094 A+B for Input-Output Practice (VI)121095 A+B for Input-Output Practice (VI
2、I)131096 A+B for Input-Output Practice (VIII)142000 ASCII码排序162001计算两点间的距离172002计算球体积192003求绝对值202004成绩转换212005第几天?222006求奇数的乘积242007平方和与立方和262008数值统计272009求数列的和282010水仙花数292011多项式求和312012素数判定332014青年歌手大奖赛_评委会打分342015偶数求和362016数据的交换输出382017字符串统计402019数列有序!412020绝对值排序432021发工资咯:452033人见人爱A+B462039三角形
3、482040亲和数4991 / 911001 Sum ProblemProblem DescriptionHey, wele to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + . + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one
4、line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.Sample Input1100Sample Output15050AuthorDOOM III解答:#includemain() int n,i,sum; sum=0; while(scanf(%d,&n)!=-1) sum=0; for(i=0;i=n;i+)sum+=i; printf(%dnn,sum);1089 A+B for Input-Output Practice (I)P
5、roblem DescriptionYour task is to Calculate a + b.Too easy?! Of course! I specially designed the problem for acm beginners. You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim. InputThe input will consist of a series of pa
6、irs of integers a and b, separated by a space, one pair of integers per line. OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample Input1 510 20Sample Output630AuthorlcyRemendJGShining解答:#include ma
7、in() int a,b; while(scanf(%d%d,&a,&b)!=EOF)printf(%dn,a+b);1090 A+B for Input-Output Practice (II)Problem DescriptionYour task is to Calculate a + b.InputInput contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, on
8、e pair of integers per line. OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample Input21 510 20Sample Output630AuthorlcyRemendJGShining解答:#include#define M 1000void main() int a ,b,n,jM,i;/printf(p
9、lease input n:n); scanf(%d,&n);for(i=0;in;i+) scanf(%d%d,&a,&b); /printf(%d %d,a,b); ji=a+b; i=0; while(in) printf(%d,ji); i+; printf(n); 1091A+B for Input-Output Practice (III)Problem DescriptionYour task is to Calculate a + b.InputInput contains multiple test cases. Each test case contains a pair
10、of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. Sample Inp
11、ut1 510 200 0Sample Output630AuthorlcyRemendJGShining解答:#include main() int a,b; scanf(%d %d,&a,&b); while(!(a=0&b=0) printf(%dn,a+b);scanf(%d %d,&a,&b); 1092A+B for Input-Output Practice (IV)Problem DescriptionYour task is to Calculate the sum of some integers.InputInput contains multiple test case
12、s. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in
13、 input. Sample Input4 1 2 3 45 1 2 3 4 50 Sample Output1015AuthorlcyRemendJGShining解答:#include int main() int n,sum,i,t; while(scanf(%d,&n)!=EOF&n!=0) sum=0; for(i=0;in;i+) scanf(%d,&t); sum=sum+t; printf(%dn,sum); 1093 A+B for Input-Output Practice (V)Problem DescriptionYour task is to calculate th
14、e sum of some integers.InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. OutputFor each group of input integers you should output their sum in one line, and with one line of output for each lin
15、e in input. Sample Input24 1 2 3 45 1 2 3 4 5Sample Output1015Authorlcy解答:#includemain() int n,a,b,i,j,sum; sum=0; while(scanf(%dn,&n)!=-1) for(i=0;in;i+) scanf(%d,&b); for(j=0;jb;j+) scanf(%d,&a);sum+=a; printf(%dn,sum);sum=0; 1094 A+B for Input-Output Practice (VI)Problem DescriptionYour task is t
16、o calculate the sum of some integers.InputInput contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line. OutputFor each test case you should output the sum of N integers in one line, and with one line of output for each lin
17、e in input. Sample Input4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRemendJGShining解答:#includemain() int n,a,b,i,j,sum;sum=0; while(scanf(%dn,&n)!=-1) for(j=0;jn;j+) scanf(%d,&a); sum+=a; printf(%dn,sum); sum=0; Copy to Clipboard Save to File1095A+B for Input-Output Practice (VII)Problem Descripti
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 部分 ACM 题目 问题 详解

链接地址:https://www.desk33.com/p-11404.html