spoj 001

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值