A+B 37种语言!
必须点赞!!!
我可是辛辛苦苦肝了1年的啊!!!
Ada2012 (GNAT 9.2.1) 语言
with Ada.Text_IO,Ada.Integer_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure Main is
A: Integer;
B: Integer;
begin
Get(A);
Get(B);
Put(A+B,Width=>0);New_Line;
end Main;
Awk (GNU Awk 4.1.4) 语言
$0=$1+$2a
没想到吧,可以这么短!
Bash (5.0.11) 语言
read a b
echo $(($a+$b))
Brainfuck (bf 20041219) 语言
>,>++++[<-------->-]<[>++++[<---->-]<<[>++++++++++<-]>[<+>-],>++++[<-------->-]<]
>,----------[>++++++[<------>-]<--<[>++++++++++<-]>[<+>-],----------]
<<[>+<-]>[>>>>[-]+[[-]+<---------[++++++++++>[>>]>>-<<<]>>>+]<<<<[<<]<<-]
>>>>+[>>]<<[[-]++++++++[<++++++>-]<.[-]<]
++++++++++.
拉拉拉,史上最骚语言!
C (GCC 9.2.1) 语言
#include <stdio.h>
int main(void){
int a;
int b;
int c;
scanf("%d",&a);
scanf("%d",&b);
c = a + b;
printf("%d\n",c);
return 0;
}
终于来点正常的了
C# (.NET Core 3.1.201) 语言
using System;
namespace Sample101
{
class Program
{
static void Main(string[] args)
{
string[] str = Console.ReadLine().Split(" ");
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
Console.WriteLine(a + b);
}
}
}
C++ (GCC 9.2.1) 语言
#include <bits/stdc++.h>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
cout << A + B << endl;
}
最普通的语言
Clojure (1.10.1.536) 语言
;; (defn create-input
;; [arg]
;; (->> (.split arg " ")
;; (map #(Integer/parseInt %))))
(defn create-input
[arg]
(->> (clojure.string/split arg #" ")
(map #(Integer/parseInt %))))
(println (reduce #'+ (create-input (read-line))))
Common Lisp (SBCL 2.0.3) 语言
(let ((x (+ (read) (read))))
(format t "~A~%" X))
Crystal (0.33.0) 语言
a, b = read_line.split.map(&.to_i)
puts a + b
Cython (0.29.16) 语言
print(eval(input().replace(*' +')))
Dash (0.5.8) 语言
read A B;
echo $((A+B))
F# (.NET Core 3.1.201) 语言
let a, b =
stdin.ReadLine().Split()
|> Array.map int
|> fun ary -> ary.[0], ary.[1]
a + b |> stdout.WriteLine
Fortran (GNU Fortran 9.2.1) 语言
program ex5
implicit none
integer a,b
read *, a,b
print'(i0)', a+b
end program ex5
Go (1.14.1) 语言
package main
import (
"fmt"
)
func main() {
var a, b int
fmt.Scan(&a)
fmt.Scan(&b)
fmt.Println(a + b)
}
熟悉的语言~~~
Haskell (GHC 8.8.3) 语言
{-
0 <= A,B <= 100
A,B :: Int
-}
--input
{-
A B
-}
--output
{-
A+B\n
-}
main :: IO ()
main = do
input <- getLine
let [a,b] = map (\t -> read t :: Int) (words input)
print $ a+b
Java (OpenJDK 11.0.6) 语言
import java.util.*;
public class Main {
public static void main(String[] args) {
var sc = new Scanner(System.in);
var a = Integer.parseInt(sc.next());
var b = Integer.parseInt(sc.next());
System.out.println(a+b);
}
}
JavaScript (Node.js 12.16.1) 语言
function f(data) {
data = data.split(' ')
console.log(Number(data[0])+Number(data[1]))
}
f(require("fs").readFileSync("/dev/stdin", "utf8"));
Julia (1.4.0) 语言
a, b = parse.(Int, split(readline()))
println(a + b)
Kotlin (1.3.71) 语言
fun main() {
val (a, b) = readLine()!!.split(' ')
println(a.toInt() + b.toInt())
}
Lua (Lua 5.3.5) 语言
a, b = io.read("*n", "*n")
print(a + b)
Nim (1.0.6) 语言
#sample
#import strformat, strscans, macros, sequtils, strutils
import strformat, strscans, macros, sequtils, strutils
var a,b : int
(a,b) = stdin.readLine.split.map parseInt
echo a + b
OCaml (4.10.0) 语言
let () =
Scanf.scanf "%d %d" @@ fun a b ->
Printf.printf "%d\n" (a + b)
PHP (7.4.4) 语言
<?php
fscanf(STDIN, "%d%d", $A, $B);
echo $A+$B,"\n";
嘿嘿,这个语言咋们是不是在luogu里面很熟悉呀
Perl (v5.18.2) 语言
print<>=~$"*$`+$',$/
Python (2.7.6) 语言
a,b=map(int,raw_input().split())
print(a+b)
Pascal (FPC 3.0.4) 语言
var a, b: longint;
begin
readln(a,b);
writeln(a+b);
end.
Racket (7.6) 语言
#lang racket
(module+ main
(define (read-line*) (read-line (current-input-port) 'any))
(define (read-words) (string-split (read-line*)))
(define (read-numbers) (map string->number (read-words)))
(match-let* ([(list a b) (read-numbers)])
(displayln (+ a b) )
)
)
Ruby (2.7.1) 语言
a,b = gets.split(" ").map(&:to_i)
puts(a + b)
Rust (1.42.0) 语言
use whiteread::parse_line;
fn main(){
let (a, b): (i32, i32) = parse_line().unwrap();
println!("{}",a+b);
}
Scala (2.13.1) 语言
import java.util.Scanner;
object Main extends App {
val sc = new Scanner(System.in);
val a = sc.nextInt();
val b = sc.nextInt();
println(a + b);
}
Scheme (Gauche 0.9.9) 语言
(print (+ (read) (read)))
Sed (4.4) 语言
s/ /+/;s/.*/echo $((&))/e
Swift (5.2.1) 语言
var a = readLine()!.split(separator: " ")
print(Int(a[0])! + Int(a[1])!)
TypeScript (3.8) 语言
import * as fs from 'fs'
const input = fs.readFileSync("/dev/stdin", "utf8").split(" ")
console.log(+input[0] + +input[1])
Visual Basic (.NET Core 3.1.101) 语言
module m
#Region "In/Out"
Function Read() As String
Return Console.ReadLine
End Function
Function ReadLong() As Long
Return CLng(Console.ReadLine)
End Function
Function ReadLongs() As Long()
Dim str1() As String = Console.ReadLine.Split(" "c)
Dim N As Integer = str1.Count - 1
Dim Rval(N) As Long
For I As Integer = 0 To N
Rval(I) = CLng(str1(I))
Next
Return Rval
End Function
Function ReadStrings() As String()
Return Console.ReadLine.Split(" "c)
End Function
Sub Write(ByVal str As String)
Console.WriteLine(str)
End Sub
#End Region
sub main()
dim AB=readlongs()
write(AB(0)+AB(1))
end sub
end module
Zsh (5.4.2) 语言
#!bin/zsh
read A B
echo $(( A+B ))
dc (1.4.1) 语言超级压轴!
?+p
没错,就是这么短,AC。
还有Node.js LTS
Pascal
加上了
Node.js 我已经写了
ooo
如果Saber有dc就好了QwQdc必须赞