部分ACM题目与答案

上传人:桔**** 文档编号:509082295 上传时间:2023-12-11 格式:DOC 页数:53 大小:241KB
返回 下载 相关 举报
部分ACM题目与答案_第1页
第1页 / 共53页
部分ACM题目与答案_第2页
第2页 / 共53页
部分ACM题目与答案_第3页
第3页 / 共53页
部分ACM题目与答案_第4页
第4页 / 共53页
部分ACM题目与答案_第5页
第5页 / 共53页
点击查看更多>>
资源描述

《部分ACM题目与答案》由会员分享,可在线阅读,更多相关《部分ACM题目与答案(53页珍藏版)》请在金锄头文库上搜索。

1、真诚为您提供优质参考资料,若有不当之处,请指正。 1001 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 Inpu

2、t-Output Practice (VII)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发工资咯:)

3、452033人见人爱A+B462039三角形482040亲和数49 / 1001 Sum ProblemProblem DescriptionHey, welcome 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,

4、output SUM(n) in one 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 Inp

5、ut-Output Practice (I)Problem 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 co

6、nsist of a series of pairs 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 Output630AuthorlcyRecomm

7、endJGShining解答:#include main() 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

8、 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 Input21 510 20Sample Output630AuthorlcyRecommendJGShining 解答:#include#define M 1000void

9、main() int a ,b,n,jM,i; /printf(please 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); 1091 A+B for Input-Output Practice (III)Problem DescriptionYour task is to Calculate a + b.InputInput contains multiple test cas

10、es. Each test case contains a pair 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

11、 for each line in input. Sample Input1 510 200 0Sample Output630AuthorlcyRecommendJGShining解答:#include main() int a,b; scanf(%d %d,&a,&b); while(!(a=0&b=0) printf(%dn,a+b); scanf(%d %d,&a,&b); 1092 A+B for Input-Output Practice (IV)Problem DescriptionYour task is to Calculate the sum of some integer

12、s.InputInput contains multiple test cases. 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

13、with one line of output for each line in input. Sample Input4 1 2 3 45 1 2 3 4 50 Sample Output1015AuthorlcyRecommendJGShining解答:#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 DescriptionYo

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号