杭电acm部分题目及答案答案
自己刷的题这是我在杭电做题的记录,希望我的分享对你有帮助!!!1001 Sum Problem***********************************************************21089 A+B for -Output Practice (I)********************************41090 A+B for -Output Practice (II)********************************61091 A+B for -Output Practice (III)****************************************81092 A+B for -Output Practice (IV)********************************91093 A+B for -Output Practice (V)********************************111094 A+B for -Output Practice (VI)***************************************121095 A+B for -Output Practice (VII)*******************************131096 A+B for -Output Practice (VIII)******************************14How to Type***************************************************************16 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.The will consist of a series of integers n, one integer per line.OutputFor each case, 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 1100Sample Output15050AuthorDOOM III解答:#includemain(){int n,i,sum;sum=0;while((scanf(“%d“,for(i=0;imain(){int a,b;while(scanf(“%d%d“,}1090 A+B for -Output Practice (II)Problem DescriptionYour task is to Calculate a + b. 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, one pair of integers per line. OutputFor each pair of 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 . Sample 21 510 20Sample Output630AuthorlcyRecommendJGShining解答:#include#define M 1000void main(){ int a ,b,n,j[M],i;//printf(“please n:\n“);scanf(“%d“,for(i=0;imain(){int a,b;scanf(“%d %d“,while(!(a==0scanf(“%d %d“,}}1092 A+B for -Output Practice (IV)Problem DescriptionYour task is to Calculate the sum of some integers. 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 and this test case is not to be processed.OutputFor each group of integers you should output their sum in one line, and with one line of output for each line in . Sample 4 1 2 3 45 1 2 3 4 50 Sample Output1015AuthorlcyRecommendJGShining解答:#include int main(){int n,sum,i,t;while(scanf(“%d“,for(i=0;imain(){int n,a,b,i,j,sum;sum=0;while(scanf(“%d\n“,imain(){int n,a,b,i,j,sum;sum=0;while(scanf(“%d\n“,jmain(){int a,b;while(scanf(“%d%d“,}1096 A+B for -Output Practice (VIII)Problem DescriptionYour task is to calculate the sum of some integers. 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