关闭

山东理工大学ACM平台题答案 1013 A+B for Input-Output Practice (IV)

1192人阅读 评论(0) 收藏 举报
分类:

A+B for Input-Output Practice (IV)

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

Your task is to Calculate the sum of some integers.

输入

Input 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.

输出

For each group of input integers you should output their sum in one line, and with one line of output for each line in input.

示例输入

4 1 2 3 4
5 1 2 3 4 5
0

示例输出

10
15  下面有两个答案 二者很相像 请您找不同 其中有一道是对的 开动你的大脑吧
 
 
1 

#include<stdio.h> void main() {   int a,b,n,sum;   sum=0;   a=1;   b=1;   n=1;   while(n!=0)   {     scanf("%d ",&n);  if(n==0)break;  for(a=1;a<=n;a++)  {  scanf("%d",&b);     sum=sum+b;    }   printf("%d\n",sum); } }

 

2

#include<stdio.h>

void main() { int n=1; int a,s; while(n!=0) { scanf("%d",&n); if(n==0) break; s=0; for(int i=0;i<n;i++) { scanf("%d",&a); s=s+a; } printf("%d\n",s); } }

 

0
0
查看评论

「HD_ACM」A+B for Input-Output Practice (IV)

Problem Description Your task is to Calculate the sum of some integers. ->你的任务是计算一些整数相加   Input Input contains multiple...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-02 21:26
  • 936

HDU-1092-A+B for Input-Output Practice (IV)(继续!)

A+B for Input-Output Practice (IV) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub...
  • qq_16542775
  • qq_16542775
  • 2015-07-15 14:08
  • 1336

杭电ACM 1089 A+B for Input-Output Practice (I)

A+B for Input-Output Practice (I) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission...
  • neuxxm
  • neuxxm
  • 2012-11-12 00:54
  • 1732

「HD_ACM」A+B for Input-Output Practice (VII)

Problem Description Your task is to Calculate a + b. ->你的任务是计算A + B   Input The input will consist of a series of ...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-02 21:59
  • 1784

【杭电oj】1090 - A+B for Input-Output Practice (II)

A+B for Input-Output Practice (II) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub...
  • Bear1998
  • Bear1998
  • 2016-01-13 20:42
  • 757

杭电ACM 1090 (A+B for Input-Output Practice (II))

#include using namespace std; int main() { int n,a,b,c; cin>>n; for(int i=0;i<n;i++) { cin>>a>>...
  • hjl243632044
  • hjl243632044
  • 2012-01-21 19:22
  • 1299

「HD_ACM」 A+B for Input-Output Practice (II)

Problem Description Your task is to Calculate a + b. ->你的任务是计算A + B   Input Input contains an integer N in the fir...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-01 22:41
  • 1665

[水题][hdoj_1092]A+B for Input-Output Practice (IV)

// hdoj_1092 A+B for Input-Output Practice (IV) #include int main(void) { int a, n, i, sum; while(scanf("%d", &n) && n != ...
  • litiouslove
  • litiouslove
  • 2012-07-31 01:06
  • 2050

山东理工大学ACM平台题答案关于C语言 1012 A+B for Input-Output Practice (III)

A+B for Input-Output Practice (III) Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Your task is to Calculate ...
  • u012707729
  • u012707729
  • 2013-12-13 20:56
  • 964

HDU_ACM_A+B for Input-Output Practice (III)

如果有啥不正确或不合适的地方 希望能在评论里面指出
  • qq_20141243
  • qq_20141243
  • 2016-03-26 23:54
  • 123
    个人资料
    • 访问:202833次
    • 积分:3392
    • 等级:
    • 排名:第11752名
    • 原创:110篇
    • 转载:7篇
    • 译文:28篇
    • 评论:9条