牛客网python_牛客网在线判题系统使用帮助

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

while (in.hasNextInt()) {//注意while处理多个case int a = in.nextInt();

int b = in.nextInt();

System.out.println(a + b);

}

}

}

Python

import sys

try:

while True:

line = sys.stdin.readline().strip()

if line == '':

break

lines = line.split()

print int(lines[0]) + int(lines[1])

except:

pass

Python3

import sys

for line in sys.stdin:

a = line.split()

print(int(a[0]) + int(a[1]))

while(line=readline()){

var lines = line.split(' ');

var a = parseInt(lines[0]);

var b = parseInt(lines[1]);

print(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]));

});

C#

public class Program {

public static void Main() {

string line;

while ((line = System.Console.ReadLine ()) != null) {// 注意,如果输入是多个测试用例,请通过while循环处理多个测试用例

string[] tokens = line.Split();

System.Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));

}

}

}

Php

while(fscanf(STDIN, "%d %d", $a, $b) == 2)

echo ($a + $b)."\n";

Go

package main

import (

"fmt"

)

func main() {

a:=0

b:=0

for {

n, _ := fmt.Scan(&a,&b)

if n == 0 {

break

} else {

fmt.Printf("%d\n",a+b)

}

}

}

R语言

lines=readLines("stdin")

for(l in lines){

if(l == ""){

break;

}

ll = strsplit(l, " ")[[1]]

a=ll[1];

b=ll[2];

cat(as.numeric(a)+as.numeric(b));

cat('\n');

}

Ruby

a, b = gets.split(" ").map {|x| x.to_i}

puts (a + b)

Rust

fn main() {

let mut input = String::new();

std::io::stdin().read_line(&mut input).unwrap();

let nums:Vec= input.trim().split(" ").collect();

let num1: i32 = nums[0].parse().unwrap();

let num2: i32 = nums[1].parse().unwrap();

let sum = num1 + num2;

println!("{}\n", sum);

} Swift

import Foundation

while let line = readLine() {

let parts = line.split(separator: " ")

print(Int(parts[0])! + Int(parts[1])!)

} ObjectC

#import

int main(int argc,char * argv[])

{

NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];

int a,b;

while(scanf("%d %d",&a, &b) != EOF)

printf("%d\n",a+b);

[pool drain];

return 0;

} Pascal

var i, j : integer;

begin

while not eof do

begin

readln(i, j);

writeln(i + j);

end;

end.

matlab

try

while 1

line = input('', 's');

lines = strsplit(line);

printf("%d\n", str2num(lines{1}) + str2num(lines{2}));

end

catch

end Bash

#!/bin/bash

read -a arr

while [ ${#arr[@]} -eq 2 ]

do

sum=$((${arr[0]}+${arr[1]}))

echo $sum

read -a arr

done

exit 0

3. 判题系统状态

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值