加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

P1001 A+B Problem

发布时间:2020-12-16 09:17:48 所属栏目:百科 来源:网络整理
导读:题目描述 输入两个整数a,b,输出它们的和(|a|,|b|=10^9)。 输入格式 两个整数以空格分开 输出格式 一个数 输入输出样例 输入 #1 20 30 输出 #1 50 代码 C #include stdio.h int main() { int a,b; scanf( " %d%d " ,a, b); printf( " %d " ,a+ b); return 0

题目描述

输入两个整数a,b,输出它们的和(|a|,|b|<=10^9)。

输入格式

两个整数以空格分开

输出格式

一个数

输入输出样例

输入 #1

20 30

输出 #1

50

代码

C

#include <stdio.h>
int main() 
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a+b);
    return 0;
}

C++

#include <iostream>
#include <cstdio>
using namespace std;
int main() 
{
    int a,b;
    cin >> a >> b;
    cout << a+b;
    return 0;
}

Pascal

var a,b: longint;
begin
    readln(a,b);
    writeln(a+b);
end.

Python

python2

s = raw_input().split()
print int(s[0]) + int(s[1])

python3

s = input().split()
print(int(s[0]) + int(s[1]))

Java

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner cin=new Scanner(System.in);
        int a = cin.nextInt(),b = cin.nextInt();
        System.out.println(a+b);
    }
}

JavaScript (Node.js)

const fs = require(‘fs‘)
const data = fs.readFileSync(‘/dev/stdin‘)
const result = data.toString(‘ascii‘).trim().split(‘ ‘).map(x => parseInt(x)).reduce((a,b) => a + b,0)
console.log(result)
process.exit()

PHP

<?php
$input = trim(file_get_contents("php://stdin"));
list($a,$b) = explode(‘ ‘,$input);
echo $a + $b;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读