C++ 代码
#include <iostream>
using namespace std;
int main () {
int a, b;
cin >> a >> b;
cout << a + b << endl;
return 0;
}
C 代码
#include <stdio.h>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
return 0;
}
Java 代码
import java.io.*;
import java.util.*;
public class Main {
public static void main(String args[]) throws Exception {
Scanner cin=new Scanner(System.in);
var a = cin.nextInt();
var b = cin.nextInt();
System.out.println(a + b);
}
}
Python 代码
import sys
for line in sys.stdin:
print sum(map(int, line.split()))
Python3 代码
import sys
for line in sys.stdin:
print(sum(map(int, line.split())))
Javascript 代码
var fs = require('fs');
var buf = '';
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if (chunk) buf += chunk.toString();
});
process.stdin.on('end', function() {
buf.split('\n').forEach(function(line) {
var tokens = line.split(' ').map(function(x) { return parseInt(x); });
if (tokens.length != 2) return;
console.log(tokens.reduce(function(a, b) { return a + b; }));
});
});
作者:yxc
链接:https://www.acwing.com/solution/content/729/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
共 8 条回复
请使用C++11(Clang)
最关键还AC了
搬运至CPP巨佬
链接:https://www.luogu.com.cn/problem/P1001
https://www.luogu.com.cn/problem/P1001
C
C++
Pascal
Python2
Python3
Java
JavaScript (Node.js)
Ruby
C++ 代码
#include
using namespace std;
int main () { int a, b; cin >> a >> b; cout << a + b << endl; return 0; } C 代码
#include <stdio.h>
int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", a + b); return 0; } Java 代码
import java.io.; import java.util.;
public class Main { public static void main(String args[]) throws Exception { Scanner cin=new Scanner(System.in); var a = cin.nextInt(); var b = cin.nextInt(); System.out.println(a + b); } } Python 代码
import sys
for line in sys.stdin: print sum(map(int, line.split())) Python3 代码
import sys
for line in sys.stdin: print(sum(map(int, line.split()))) Javascript 代码
var fs = require('fs'); var buf = '';
process.stdin.on('readable', function() { var chunk = process.stdin.read(); if (chunk) buf += chunk.toString(); });
process.stdin.on('end', function() { buf.split('\n').forEach(function(line) { var tokens = line.split(' ').map(function(x) { return parseInt(x); }); if (tokens.length != 2) return; console.log(tokens.reduce(function(a, b) { return a + b; })); }); }); 作者:yxc 链接:https://www.acwing.com/solution/content/729/ 来源:AcWing 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
共 1 条回复
感觉还是c++** or **c语言最容易看懂,其他要么是没有加号要么就是一大堆看不懂