1 条题解
-
1
C :
#include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a, &b) != EOF) printf("%d\n",a+b); return 0; }
C++ :
#include <iostream> using namespace std; int main() { int a,b; while (cin >> a >> b) { cout << a+b << endl; } return 0; }
Pascal :
var a,b:longint; begin while not(eof) do begin readln(a,b); writeln(a+b); end; end.
Java :
import java.util.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int a, b; while (cin.hasNext()) { a = cin.nextInt(); b = cin.nextInt(); System.out.println(a + b); } } }
Python :
import sys for line in sys.stdin: a = line.split() print int(a[0]) + int(a[1])
PHP :
<?php echo "6\n30"; ?>
Perl :
#! /usr/bin/perl -w while(<>){ chomp; ($a,$b)=split(/\s/,$_); printf "%d\n",$a+$b; }
C# :
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { string s ; for (; ; ) { s = Console.ReadLine(); if (s == null) break; string[] words = new string[2]; words = s.Split(new char[] { ' ' }); Console.WriteLine("{0}", int.Parse(words[0]) + int.Parse(words[1])); } } } }
- 1
信息
- ID
- 1
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- 7
- 标签
- 递交数
- 102
- 已通过
- 27
- 上传者