diff --git a/ifj2017/tests/96_programs/03.code b/ifj2017/tests/96_programs/03.code new file mode 100644 index 0000000..bf3fc9d --- /dev/null +++ b/ifj2017/tests/96_programs/03.code @@ -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 diff --git a/ifj2017/tests/96_programs/03.stdout b/ifj2017/tests/96_programs/03.stdout new file mode 100644 index 0000000..d176720 --- /dev/null +++ b/ifj2017/tests/96_programs/03.stdout @@ -0,0 +1 @@ + 30 10 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/04.code b/ifj2017/tests/96_programs/04.code new file mode 100644 index 0000000..8d06bde --- /dev/null +++ b/ifj2017/tests/96_programs/04.code @@ -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 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/04.stdin b/ifj2017/tests/96_programs/04.stdin new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/ifj2017/tests/96_programs/04.stdin @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/04.stdout b/ifj2017/tests/96_programs/04.stdout new file mode 100644 index 0000000..17c5a0b --- /dev/null +++ b/ifj2017/tests/96_programs/04.stdout @@ -0,0 +1 @@ +? Soucet cisel do 100 je 5050 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/05.code b/ifj2017/tests/96_programs/05.code new file mode 100644 index 0000000..5290fa9 --- /dev/null +++ b/ifj2017/tests/96_programs/05.code @@ -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 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/05.stdin b/ifj2017/tests/96_programs/05.stdin new file mode 100644 index 0000000..06ee502 --- /dev/null +++ b/ifj2017/tests/96_programs/05.stdin @@ -0,0 +1,3 @@ +100 +150 +125 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/05.stdout b/ifj2017/tests/96_programs/05.stdout new file mode 100644 index 0000000..f886684 --- /dev/null +++ b/ifj2017/tests/96_programs/05.stdout @@ -0,0 +1 @@ +? ? ? 150 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/06.code b/ifj2017/tests/96_programs/06.code new file mode 100644 index 0000000..0fc3c80 --- /dev/null +++ b/ifj2017/tests/96_programs/06.code @@ -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 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/06.stdin b/ifj2017/tests/96_programs/06.stdin new file mode 100644 index 0000000..58d07ea --- /dev/null +++ b/ifj2017/tests/96_programs/06.stdin @@ -0,0 +1 @@ +1456534 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/06.stdout b/ifj2017/tests/96_programs/06.stdout new file mode 100644 index 0000000..09f0202 --- /dev/null +++ b/ifj2017/tests/96_programs/06.stdout @@ -0,0 +1 @@ +? 7 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/07.code b/ifj2017/tests/96_programs/07.code new file mode 100644 index 0000000..a7cb084 --- /dev/null +++ b/ifj2017/tests/96_programs/07.code @@ -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 + diff --git a/ifj2017/tests/96_programs/07.stdin b/ifj2017/tests/96_programs/07.stdin new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/ifj2017/tests/96_programs/07.stdin @@ -0,0 +1 @@ +10 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/07.stdout b/ifj2017/tests/96_programs/07.stdout new file mode 100644 index 0000000..d559cc6 --- /dev/null +++ b/ifj2017/tests/96_programs/07.stdout @@ -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 diff --git a/ifj2017/tests/96_programs/08.code b/ifj2017/tests/96_programs/08.code new file mode 100644 index 0000000..3d1ed9f --- /dev/null +++ b/ifj2017/tests/96_programs/08.code @@ -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 diff --git a/ifj2017/tests/96_programs/08.stdin b/ifj2017/tests/96_programs/08.stdin new file mode 100644 index 0000000..b31cdf0 --- /dev/null +++ b/ifj2017/tests/96_programs/08.stdin @@ -0,0 +1,2 @@ +10 +20 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/08.stdout b/ifj2017/tests/96_programs/08.stdout new file mode 100644 index 0000000..70047db --- /dev/null +++ b/ifj2017/tests/96_programs/08.stdout @@ -0,0 +1,4 @@ +Enter two positive integers: +? +? +Prime numbers between 10 and 20 are 11 13 17 19 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/09.code b/ifj2017/tests/96_programs/09.code new file mode 100644 index 0000000..bc3f47c --- /dev/null +++ b/ifj2017/tests/96_programs/09.code @@ -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 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/09.stdout b/ifj2017/tests/96_programs/09.stdout new file mode 100644 index 0000000..f18ec39 --- /dev/null +++ b/ifj2017/tests/96_programs/09.stdout @@ -0,0 +1 @@ + 2 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/10.code b/ifj2017/tests/96_programs/10.code new file mode 100644 index 0000000..52504e8 --- /dev/null +++ b/ifj2017/tests/96_programs/10.code @@ -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 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/10.stdin b/ifj2017/tests/96_programs/10.stdin new file mode 100644 index 0000000..aa7393c --- /dev/null +++ b/ifj2017/tests/96_programs/10.stdin @@ -0,0 +1,2 @@ +366 +60 \ No newline at end of file diff --git a/ifj2017/tests/96_programs/10.stdout b/ifj2017/tests/96_programs/10.stdout new file mode 100644 index 0000000..74ed10e --- /dev/null +++ b/ifj2017/tests/96_programs/10.stdout @@ -0,0 +1,4 @@ +Enter two positive integers: +? +? +G.C.D of 366 and 60 is 6 \ No newline at end of file