Skip to content

Instantly share code, notes, and snippets.

@jlfwong
Created November 8, 2009 17:53
Show Gist options
  • Save jlfwong/229406 to your computer and use it in GitHub Desktop.
Save jlfwong/229406 to your computer and use it in GitHub Desktop.
//TEST AC - CPP (g++)
#include <iostream>
using namespace std;
int main() {
int n;
while(1) {
cin >> n;
if (n == 42) break;
cout << n << endl;
}
return 0;
}
#TEST AC - Perl
while (1)
{
$n = <STDIN>;
if ($n == 42) {
last;
}
print $n
}
#!/bin/bash
# TEST AC - BASH
while true; do
read n
if [ $n -eq 42 ]; then
break
fi
echo "$n"
done
{TEST AC - GPC Pascal}
program TEST;
var n:integer;
begin
while true do
begin
readln(n);
if n = 42 then begin
break;
end;
writeln(n);
end;
end.
//TEST AC - (gcc C99)
#include <stdio.h>
int main() {
int n;
while(1) {
scanf("%d",&n);
if (n == 42) break;
printf("%d\n",n);
}
return 0;
}
<?
//TEST AC - PHP
while(1) {
fscanf(STDIN,"%d",$n);
if ($n == 42) break;
print "$n\n";
}
?>
#TEST AC - Python
while 1:
num = input()
if (num == 42):
break
print num
#TEST AC - Ruby
while 1
n = gets.to_i
if n == 42
break
end
puts n
end
//TEST AC - Java
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(true) {
int n = in.nextInt();
if (n == 42) break;
System.out.println(n);
}
}
}
//TEST AC - C# (gmcs + Mono)
using System;
class WelcomeCSS {
static void Main() {
while(true) {
int n;
n = int.Parse(Console.ReadLine());
if (n == 42) break;
Console.WriteLine(n);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment