Commit dec73056 authored by uwdkn's avatar uwdkn

Merge branch 'lexer-tests-group-5' into 'master'

Lexer tests - group 5

See merge request !1
parents 1fbee7c0 69fc9ece
class ArrayMax {
public static void main(String[] args) {
ArrayMax tmp = new ArrayMax();
int a[] = new int[10];
int i = 0;
while(i < 10) {
a[i] = System.in.read();
i = i + 1;
}
System.out.write(tmp.max(a, 10));
System.out.flush();
}
/*
Calculates maximal value of array a
*/
public int max(int[] a, int length) {
if(length <= 0) return -1;
int max = a[0];
int i = 1;
while(i < length) {
if(a[i] > max) {
max = a[i];
}
i = i + 1;
}
return max;
}
}
class
identifier ArrayMax
{
public
static
void
identifier main
(
identifier String
[
]
identifier args
)
{
identifier ArrayMax
identifier tmp
=
new
identifier ArrayMax
(
)
;
int
identifier a
[
]
=
new
int
[
integer literal 10
]
;
int
identifier i
=
integer literal 0
;
while
(
identifier i
<
integer literal 10
)
{
identifier a
[
identifier i
]
=
identifier System
.
identifier in
.
identifier read
(
)
;
identifier i
=
identifier i
+
integer literal 1
;
}
identifier System
.
identifier out
.
identifier write
(
identifier tmp
.
identifier max
(
identifier a
,
integer literal 10
)
)
;
identifier System
.
identifier out
.
identifier flush
(
)
;
}
public
int
identifier max
(
int
[
]
identifier a
,
int
identifier length
)
{
if
(
identifier length
<=
integer literal 0
)
return
-
integer literal 1
;
int
identifier max
=
identifier a
[
integer literal 0
]
;
int
identifier i
=
integer literal 1
;
while
(
identifier i
<
identifier length
)
{
if
(
identifier a
[
identifier i
]
>
identifier max
)
{
identifier max
=
identifier a
[
identifier i
]
;
}
identifier i
=
identifier i
+
integer literal 1
;
}
return
identifier max
;
}
}
EOF
switch protected a 21 _ u ++ 1-b
package package packagee hj 123 __ !
ja bool break ; ; ; = a(())
14360
switch
protected
identifier a
integer literal 21
identifier _
identifier u
++
integer literal 1
-
identifier b
package
package
identifier packagee
identifier hj
integer literal 123
identifier __
!
identifier ja
identifier bool
break
;
;
;
=
identifier a
(
(
)
)
integer literal 14360
EOF
class Fibonacci {
public static void main(String[] args) {
Fibonacci tmp = new Fibonacci();
int a = System.in.read();
System.out.write(tmp.fibonacci(a));
System.out.flush();
}
public int fibonacci(int n) {
if(n <= 1) return n;
else return fibonacci(n - 1) + fibonacci(n - 2);
}
}
class
identifier Fibonacci
{
public
static
void
identifier main
(
identifier String
[
]
identifier args
)
{
identifier Fibonacci
identifier tmp
=
new
identifier Fibonacci
(
)
;
int
identifier a
=
identifier System
.
identifier in
.
identifier read
(
)
;
identifier System
.
identifier out
.
identifier write
(
identifier tmp
.
identifier fibonacci
(
identifier a
)
)
;
identifier System
.
identifier out
.
identifier flush
(
)
;
}
public
int
identifier fibonacci
(
int
identifier n
)
{
if
(
identifier n
<=
integer literal 1
)
return
identifier n
;
else
return
identifier fibonacci
(
identifier n
-
integer literal 1
)
+
identifier fibonacci
(
identifier n
-
integer literal 2
)
;
}
}
EOF
class GCD {
public static void main(String[] args) {
GCD tmp = new GCD();
int a = System.in.read();
int b = System.in.read();
System.out.write(tmp.gcd(a,b));
System.out.flush();
}
public int gcd(int a, int b) {
if(a <= 0 && b <= 0) return -1;
int t;
while(b != 0) {
t = a % b;
a = b;
b = t;
}
return a;
}
}
class
identifier GCD
{
public
static
void
identifier main
(
identifier String
[
]
identifier args
)
{
identifier GCD
identifier tmp
=
new
identifier GCD
(
)
;
int
identifier a
=
identifier System
.
identifier in
.
identifier read
(
)
;
int
identifier b
=
identifier System
.
identifier in
.
identifier read
(
)
;
identifier System
.
identifier out
.
identifier write
(
identifier tmp
.
identifier gcd
(
identifier a
,
identifier b
)
)
;
identifier System
.
identifier out
.
identifier flush
(
)
;
}
public
int
identifier gcd
(
int
identifier a
,
int
identifier b
)
{
if
(
identifier a
<=
integer literal 0
&&
identifier b
<=
integer literal 0
)
return
-
integer literal 1
;
int
identifier t
;
while
(
identifier b
!=
integer literal 0
)
{
identifier t
=
identifier a
%
identifier b
;
identifier a
=
identifier b
;
identifier b
=
identifier t
;
}
return
identifier a
;
}
}
EOF
abstract; assert; boolean; break; byte; case; catch; char; class; const; continue; default; double; do; else; enum; extends; false; finally; final; float; for; goto; if; implements; import; instanceof; interface; int; long; native; new; null; package; private; protected; public; return; short; static; strictfp; super; switch; synchronized; this; throws; throw; transient; true; try; void; volatile; while
abstract
;
assert
;
boolean
;
break
;
byte
;
case
;
catch
;
char
;
class
;
const
;
continue
;
default
;
double
;
do
;
else
;
enum
;
extends
;
false
;
finally
;
final
;
float
;
for
;
goto
;
if
;
implements
;
import
;
instanceof
;
interface
;
int
;
long
;
native
;
new
;
null
;
package
;
private
;
protected
;
public
;
return
;
short
;
static
;
strictfp
;
super
;
switch
;
synchronized
;
this
;
throws
;
throw
;
transient
;
true
;
try
;
void
;
volatile
;
while
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment