下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、【杭电ACM1000】A + B ProblemProblem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2# include <stdio.h>int main()int a, b;while(scanf("%d%d", &a, &b)!=EO
2、F)printf("%dn", a+b);return 0; 【杭电ACM1001】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
3、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 Input1 100Sample Output1 5050# include <stdio.h>int main()int n, i, sum = 0;while(scanf("%d", &n)!=EOF)for(i=1; i<=n; +i)sum = sum + i
4、;printf("%dnn", sum);sum = 0;return 0; 【杭电ACM1002】A + B Problem IIProblem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of
5、test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.OutputFor each test case, you should output t
6、wo lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.Sample Input2 1 2 11223344556677889
7、9 998877665544332211Sample OutputCase 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110#include<stdio.h>#include<string.h>int shu(char a) return (a-'0');int main() char a1000,b1000; int num1001; int n,i,j=1,al,bl,k,t;scanf("%d",&n);
8、while(n-) getchar(); if(j!=1)printf("n"); scanf("%s",a); al=strlen(a); scanf("%s",b); bl=strlen(b); k=(al>bl)?al:bl; for(i=0;i<=k;i+) numi=0; t=k; for(k;al>0&&bl>0;k-) numk+=shu(a-al)+shu(b-bl); if(numk/10) numk-1+; numk%=10; while(al>0) numk-+=shu(a-al); if(numk+1/10) numk+; numk+1%=10; while(bl>0) numk-+=shu(b-bl); if(numk+1/10) numk+; numk+1%=10; printf("Case %d:n",j+); printf(&quo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年白银市特岗教师招聘考试真题题库附答案
- 2024年黑河学院辅导员招聘备考题库附答案
- 2025天津市公务员考试数量关系专项练习题及答案参考
- 水盆工保密意识测试考核试卷含答案
- 电法勘探工岗前成果考核试卷含答案
- 幻灯机与投影机维修工安全实操考核试卷含答案
- 排水管道工安全行为能力考核试卷含答案
- 固体化妆品制造工安全知识能力考核试卷含答案
- 硝酸铵结晶造粒工保密竞赛考核试卷含答案
- 2024年湖北大学知行学院辅导员招聘考试真题汇编附答案
- 04S519小型排水构筑物1
- 光纤激光打标机说明书
- 劳动者个人职业健康监护档案
- 《两角和与差的正弦、余弦、正切公式》示范公开课教学PPT课件【高中数学人教版】
- 治理现代化下的高校合同管理
- 境外宗教渗透与云南边疆民族地区意识形态安全研究
- GB/T 28920-2012教学实验用危险固体、液体的使用与保管
- GB/T 26389-2011衡器产品型号编制方法
- GB/T 16588-2009带传动工业用多楔带与带轮PH、PJ、PK、PL和PM型:尺寸
- 人大企业经济学考研真题-802经济学综合历年真题重点
- 建筑抗震鉴定标准课件
评论
0/150
提交评论