spoj也是一个OJ
不过支持各种语言提交
居然还支持纯文本提交
于是无聊的我就试了下各种语言解决第一题
第一题简单的说就是输入一堆数
碰到42,之后就不要输出了,否则就输出
C C++
#include <stdio.h>
int nextInt()
{
int x;
scanf("%d", &x);
return x;
}
int main()
{
for (;;) {
int x = nextInt();
if (x == 42) break;
printf("%d\n", x);
}
}
CSharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (;;)
{
string line = Console.ReadLine();
if (line == "42") break;
Console.WriteLine(line);
}
}
}
}
JAVA
import java.util.*;
import java.lang.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner cin = new Scanner(System.in);
for (;;) {
int x = cin.nextInt();
if (x == 42) break;
System.out.println(x);
}
}
}
PASCAL
Program spoj001;
var
x : Longint;
begin
repeat
readln(x);
if x = 42 then break;
writeln(x);
until false;
end.
PHP
<?php
for (;;) {
fscanf(STDIN, "%d\n", $number);
if ($number == 42) break;
echo $number;
echo "\n";
}
?>
Python
import sys
for a in sys.stdin:
if int(a) != 42:
print a.strip()
else:
break
VB
Module Module1
Sub Main()
Dim flag As Boolean
flag = True
While flag
Dim x As Integer
x = Console.ReadLine()
If x <> 42 Then
Console.WriteLine(x)
Else
flag = False
End If
End While
End Sub
End Module
都是可以AC的,真是有够无聊的。可能会继续更新,毕竟我的本命JS还不知道怎么AC