Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Add program tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkobelka committed Nov 21, 2017
1 parent 4fd5938 commit c59e606
Show file tree
Hide file tree
Showing 22 changed files with 224 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ifj2017/tests/96_programs/03.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'Swap
scope

dim a as integer = 10
dim b as integer = 30

dim pomocna as integer = b
b = a
a = pomocna

print a; b;

end scope
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/03.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
30 10
18 changes: 18 additions & 0 deletions ifj2017/tests/96_programs/04.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
' Add numbers from 1 to n
scope

dim a as integer
input a

dim b as integer = 1


dim soucet as integer
do while b <= a
soucet = soucet + b
b = b + 1
loop

print !"Soucet cisel do"; a ; !" je"; soucet;

end scope
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/04.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/04.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
? Soucet cisel do 100 je 5050
22 changes: 22 additions & 0 deletions ifj2017/tests/96_programs/05.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
' Print biggest number from three numbers
scope

dim a as integer
dim b as integer
dim c as integer

input a
input b
input c

if c > b then
if c > a then
print c;
else
print a;
end if
else
print b;
end if

end scope
3 changes: 3 additions & 0 deletions ifj2017/tests/96_programs/05.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
100
150
125
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/05.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
? ? ? 150
13 changes: 13 additions & 0 deletions ifj2017/tests/96_programs/06.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
' Program to Count Number of Digits in an Integer
scope
dim a as integer
input a

dim soucet as integer
do while a <> 0
a = a \ 10
soucet = soucet + 1
loop

print soucet;
end scope
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/06.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1456534
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/06.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
? 7
25 changes: 25 additions & 0 deletions ifj2017/tests/96_programs/07.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
' Draw a pyramide
scope
print !"Enter number of rows\n";
dim rows as integer
input rows

print !"\n";

dim i as integer = 1
dim j as integer = 1

do while i <= rows
j = 1
do while j <= i


print j;
j = j + 1
loop
print !"\n";
i = i + 1
loop

end scope

1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/07.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
12 changes: 12 additions & 0 deletions ifj2017/tests/96_programs/07.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Enter number of rows
?
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
51 changes: 51 additions & 0 deletions ifj2017/tests/96_programs/08.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
' Draw primary numbers from interval
declare function prvocislo(cislo as integer) as boolean

function prvocislo(a as integer) as boolean

dim delitel as integer = a - 1

do while delitel > 1

if ((a \ delitel) * delitel) = a then
return false
else
end if
delitel = delitel - 1
loop



return true
end function

scope
dim flag as boolean
print !"Enter two positive integers:\n";

dim n1 as integer
dim n2 as integer

input n1
print !"\n";
input n2
print !"\n";

print !"Prime numbers between"; n1 ; !" and"; n2 ; !" are";

dim i as integer = n1 + 1

do while i < n2

flag = prvocislo(i)

if flag then
print i;
else
end if

i = i + 1
loop


end scope
2 changes: 2 additions & 0 deletions ifj2017/tests/96_programs/08.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
10
20
4 changes: 4 additions & 0 deletions ifj2017/tests/96_programs/08.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enter two positive integers:
?
?
Prime numbers between 10 and 20 are 11 13 17 19
10 changes: 10 additions & 0 deletions ifj2017/tests/96_programs/09.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
' Count modulo
function modulo(delitel as integer, delenec as integer) as integer
dim vysledek as integer
vysledek = delitel - (delitel\delenec)*delenec
return vysledek
end function

scope
print modulo (10, 4);
end scope
1 change: 1 addition & 0 deletions ifj2017/tests/96_programs/09.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
37 changes: 37 additions & 0 deletions ifj2017/tests/96_programs/10.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
' GCD of Two Numbers using Recursion
declare function modulo(a as integer, b as integer) as integer

function hcf(n1 as integer, n2 as integer) as integer

if n2 <> 0 then
dim vysledek as integer
vysledek = hcf(n2, modulo(n1, n2))
return vysledek
else
return n1
end if

end function

function modulo(delitel as integer, delenec as integer) as integer
dim vysledek as integer
vysledek = delitel - (delitel\delenec)*delenec
return vysledek
end function

scope

dim n1 as integer
dim n2 as integer
print !"Enter two positive integers:\n";
input n1
print !"\n";
input n2
print !"\n";

dim vysledek as integer
vysledek = hcf(n1, n2)
print !"G.C.D of"; n1; !" and"; n2 ; !" is"; vysledek;


end scope
2 changes: 2 additions & 0 deletions ifj2017/tests/96_programs/10.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
366
60
4 changes: 4 additions & 0 deletions ifj2017/tests/96_programs/10.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enter two positive integers:
?
?
G.C.D of 366 and 60 is 6

0 comments on commit c59e606

Please sign in to comment.