spoj 001
来源:互联网 发布:网络录音电话 编辑:程序博客网 时间:2024/06/05 17:49
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
<?phpfor (;;) { fscanf(STDIN, "%d\n", $number); if ($number == 42) break; echo $number; echo "\n";}?>
Python
import sysfor 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 SubEnd Module
都是可以AC的,真是有够无聊的。可能会继续更新,毕竟我的本命JS还不知道怎么AC
0 0
- spoj 001
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- SPOJ
- 随意杂记
- 2016 弱校联盟 二 B 题 E 题
- Android中Adapter的源码分析以及其中的陷阱
- HDU 5122 K.Bro Sorting(2014亚洲区北京站现场赛)
- C#实现百度地图瓦片下载器
- spoj 001
- 算法导论之线性时间排序(2)
- Codeforces Round #353 (Div. 2)E. Trains and Statistic(ST表+贪心)
- scope上绑定的函数找不到
- 好坑的题目
- 二进制与16进制的对应关系
- 算法导论之线性时间排序(3)
- 梯度(Gradient Descent) 方向梯度 (directional derivative) 以及 gradient descent梯度下降算法(1)
- hdu5831 Rikka with Parenthesis II 2016 Multi-University Training Contest 8 解题报告