1089-1096
来源:互联网 发布:天刀女性明星捏脸数据 编辑:程序博客网 时间:2024/05/01 01:41
杭电的几道a+b,控制格式的题,大概整理一下....
1089
数据会超过int,用long long 型。
/*Sample Input1 510 20 Sample Output630*/#include<stdio.h>int main(){ long long a,b; while(~scanf("%lld%lld",&a,&b)) { printf("%lld\n"a+b); } return 0;}
1090
事先给定需要测试的组数,用循环来判断是否终止
/*Sample Input21 510 20 Sample Output630*/#include<stdio.h>int main(){ long long a,b; int t; scanf("%d",&t); while(t--) { scanf("%lld%lld",&a,&b); printf("%lld\n",a+b); } return 0;}
1091
考察的特殊终止的格式,需要在循环条件处加限定
/*Sample Input1 510 200 0 Sample Output630*/#include<stdio.h>int main(){ long long a,b; while(scanf("%lld%lld",&a,&b),(a||b)) { printf("%lld\n",a+b); } return 0;}
1092
输入一个数n,后边是n个数,求和,n是0的时候程序终止
/*Sample Input4 1 2 3 45 1 2 3 4 50 Sample Output1015*/#include<stdio.h>int main(){ int i,n;long long a,s; while(scanf("%d",&n),n) { s=0; for(i=0;i<n;i++) { scanf("%lld",&a); s+=a; } printf("%lld\n",s); } return 0;}1093
输入一个数字,代表一共几组测试
每组第一个数字 n ,代表计算n个数的和,后边是 n 个数。
/*Sample Input24 1 2 3 45 1 2 3 4 5 Sample Output1015*/#include<stdio.h>int main(){ long long a,s;int i,n,t; scanf("%d",&t); while(t--) { scanf("%d",&n); s=0; for(i=0;i<n;i++) { scanf("%lld",&a); s+=a; } printf("%lld\n",s); } return 0;}
1094
读取到文件结束(相当于无限组输入),每组第一个数代表需要计算几个数的和。
/*Sample Input4 1 2 3 45 1 2 3 4 5 Sample Output1015*/#include<stdio.h>int main(){ long long a,s;int i,n; while(~scanf("%d",&n)) { s=0; for(i=0;i<n;i++) { scanf("%lld",&a); s+=a; } printf("%lld\n",s); } return 0;}
1095
计算a+b,每组之后一个空行
/*Sample Input1 510 20 Sample Output630 */#include<stdio.h>int main(){ long long a,b; while(~scanf("%lld%lld",&a,&b)) { printf("%lld\n\n",a+b); } return 0;}
1096
输入一个数,代表有多少组测试数据,每组第一个数代表本组有几个数字,输出这几个数字的和
每两组数据之间有空行,最后一组数据后没有空行。
/*Sample Input34 1 2 3 45 1 2 3 4 53 1 2 3 Sample Output10156*/#include<stdio.h>int main(){ int n,i,m,a,b,sum; scanf("%d",&n); for(i=0;i<n;i++){ sum=0; scanf("%d",&m); while(m--) { scanf("%d",&a); sum+=a; } printf("%d\n",sum); if(i<n-1) { printf("\n");} } return 0;}
1089-1096,这几个题,考查的是基本的输入和输出格式,基本上把所有的竞赛格式包括完了,格式掌握了,剩下的就是学习解决问题的方法了.....
加油!!
0 0
- 1089-1096
- 1000,1001,1089~1096
- 杭电ACM 1089-1096
- 杭电ACM 1089-1096
- 杭电ACM 1089-1096
- 杭电oj 1089--1096
- hdu 1089~1096 A+B 略。。。
- HDU 1089 1090 1091 1092 1093 1094 1095 1096
- 1089-1096:A+B for Input-Output Practice
- HDOJ 1089-1096 A+B for Input-Output Practice
- 1089~1096 (练习输入输出的8个题目)
- C++ 的简单输出输入 HDU 1089~1096
- 1089
- 1089
- HDU-#1089-1096 A+B for Input-Output Practice (I-VIII)系列
- HDUOJ A+Bproble 题目1089 1090 1091 1092 1093 1094 1095 1096
- hdoj 1089~1096 八道简单A+B问题 (JAVA)
- HDU 1089-1096 A+B for Input-Output Practice(IO系列)
- 数组的应用OC
- hihocoder 1191 小W与网格 (组合数)
- xml文件中,id、name的属性的区别
- Android 快速开发系列 ORMLite 框架最佳实践
- 遍历数组、数组排序
- 1089-1096
- UEditor扩展上传
- OC可变数组的创建与简单应用
- Android ORMLite 框架的入门用法
- 一个简单地Shell-like 的实现
- 第四天学习笔记
- OC中可变字典和不可变字典
- Dynamics CRM2015 The plug-in type does not exist in the specified assembly问题的解决方法
- 机房收费之查看数据库代码