C ( GCC 9.4.0 ) 编译器
/usr/bin/gcc -DONLINE_JUDGE -w -fmax-errors=3 -std=c11 {src_path} -lm -o {exe_path}
A+B 题目
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
C With O2 ( GCC 9.4.0 ) 编译器
/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c11 {src_path} -lm -o {exe_path}
A+B 题目
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
C++ ( G++ 9.4.0 ) 编译器
/usr/bin/g++ -DONLINE_JUDGE -w -fmax-errors=3 -std=c++14 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
C++ With O2 ( G++ 9.4.0 )
编译器
/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++14 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
C++ 17 ( G++ 9.4.0 ) 编译器
/usr/bin/g++ -DONLINE_JUDGE -w -fmax-errors=1 -std=c++17 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
C++ 17 With O2 ( G++ 9.4.0 ) 编译器
/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=1 -std=c++17 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
C++ 20 ( G++ 9.4.0 ) 编译器
/usr/bin/g++ -DONLINE_JUDGE -w -fmax-errors=1 -std=c++20 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
C++ 20 With O2 ( G++ 9.4.0 ) 编译器
/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=1 -std=c++20 {src_path} -lm -o {exe_path}
A+B 题目
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
return 0;
}
Java ( OpenJDK 1.8 ) 编译器
/usr/bin/javac {src_path} -d {exe_dir} -encoding UTF8
A+B 题目
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
System.out.println((a+b));
}
}
Python3 ( Python 3.7.5 ) 编译器
/usr/bin/python3 -m py_compile {src_path}
A+B 题目
a, b = map(int, input().split())
print(a + b)
Python2 ( Python 2.7.17 ) 编译器
/usr/bin/python -m py_compile {src_path}
A+B 题目
a, b = map(int, raw_input().split())
print a+b
Golang ( Golang 1.19 ) 编译器
/usr/bin/go build -o {exe_path} {src_path}
A+B 题目
package main
import "fmt"
func main(){
var x int
var y int
fmt.Scanln(&x,&y)
fmt.Printf("%d",x+y)
}
C# ( C# Mono 4.6.2 ) 编译器
/usr/bin/mcs -optimize+ -out:{exe_path} {src_path}
A+B 题目
using System;
using System.Linq;
class Program {
public static void Main(string[] args) {
Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Sum());
}
}
PHP ( PHP 7.2.24 ) 编译器
/usr/bin/php {src_path}
A+B 题目
<?=array_sum(fscanf(STDIN, "%d %d"));
PyPy2 ( PyPy 2.7.18 (7.3.8) ) 编译器
/usr/bin/pypy -m py_compile {src_path}
A+B 题目
print sum(int(x) for x in raw_input().split(' '))
PyPy3 ( PyPy 3.9.17 (7.3.12) ) 编译器
/usr/bin/pypy3 -m py_compile {src_path}
A+B 题目
print(sum(int(x) for x in input().split(' ')))
JavaScript Node ( Node.js 14.19.0 ) 编译器
/usr/bin/node {src_path}
A+B 题目
var readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', function(line){
var tokens = line.split(' ');
console.log(parseInt(tokens[0]) + parseInt(tokens[1]));
});
JavaScript V8 ( JavaScript V8 8.4.109 ) 编译器
/usr/bin/jsv8/d8 {src_path}
A+B 题目
const [a, b] = readline().split(' ').map(n => parseInt(n, 10));
print((a + b).toString());
Ruby ( Ruby 2.5.1 ) 编译器
/usr/bin/ruby {src_path} A+B 题目
a, b = gets.split.map(&:to_i)
puts(a + b)
Rust ( Rust 1.65.0 ) 编译器
/usr/bin/rustc -O -o {exe_path} {src_path}
A+B 题目
use std::io;
fn main() {
let mut line = String::new();
io::stdin().read_line(&mut line).expect("stdin");
let sum: i32 = line.split_whitespace()
.map(|x| x.parse::<i32>().expect("integer"))
.sum();
println!("{}", sum);
}
—— 本文来自火龙信奥(义乌睿码科技):义乌青少年信息学奥赛与编程教育平台,专注 CSP-J/S、NOIP、GESP 竞赛培训,线上线下融合教学,助力编程升学。网址:hlcoding.com