A+B 三连

刚入门的时候肯定都要做一些简单的题目,一是为了适应,二是为了增强信心。

A+B(一)

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 215   Solved: 143

Description

求两个整数的和并输出

Input

第一行输入一个整数n(1 <= n <= 100)
接着输入n组数,每组两个整数

Output

输出每组整数的和并输出

Sample Input

1
1 3
2
2 5
11 22

Sample Output

4
7
33



#include"stdio.h"
int main ()
{
     int n, b, a;
     int c;
     while (~ scanf ( "%d\n" ,&n))
     {   c=0;
         for ( int i=0;i<n;i++)
         {
             scanf ( "%d %d" ,&a,&b);
             
             c=a+b;
             printf ( "%d\n" ,c);
         }
         
     }
     return 0;
}




A+B(二)

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 200   Solved: 130

Description

Your task is to calculate the sum of some integers.

Input

Input contains multiple test cases, and one case one line.

Each case starts with an integer N(1 <= N <= 10000), and then N integers Ai( |Ai| <= 10000) follow in the same line.

Output

For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.

Sample Input

4 1 2 3 4
5 1 2 3 4 5

Sample Output

10
15



#include <iostream>
using namespace std;
int main()
{
  int n,i,a,b;
  while(scanf("%d",&n)==1)   
  {
  a = 0;
  for(i=0;i<n;i++)
  {
    scanf("%d",&b);
    a=a+b;    
  }
printf("%d\n",a);   
  }
  return 0;
}




A+B (三)

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 117   Solved: 79

Description

Your task is to calculate the sum of some integers. 

Input

Input contains an integer N(0 < N <= 100) in the first line, and then N lines follow. Each line starts with a integer M, and then M(0 < M <= 100) integers follow in the same line.

Output

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.

Sample Input

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

Sample Output

10
15



#include<stdio.h>
int main()
{
     int a, i ,m;
     while (~ scanf ( "%d" ,&m))
     {
         int b;
         for (i=0;i<m;i++)
         {
             int sum=0;
             int il;
             scanf ( "%d" ,&a);
             for (il=1;il<=a;il++)
             {
                 scanf ( "%d" ,&b);
                 sum=sum+b;
             }
             printf ( "%d\n" ,sum);
         }
     }
     return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值