diff --git a/Student/task3/function_test2021/000_main.out b/Student/task3/function_test2021/000_main.out new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/Student/task3/function_test2021/000_main.out @@ -0,0 +1 @@ +3 diff --git a/Student/task3/function_test2021/000_main.sy b/Student/task3/function_test2021/000_main.sy new file mode 100644 index 0000000..0efccbf --- /dev/null +++ b/Student/task3/function_test2021/000_main.sy @@ -0,0 +1,3 @@ +int main(){ + return 3; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/001_var_defn.out b/Student/task3/function_test2021/001_var_defn.out new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Student/task3/function_test2021/001_var_defn.out @@ -0,0 +1 @@ +8 diff --git a/Student/task3/function_test2021/001_var_defn.sy b/Student/task3/function_test2021/001_var_defn.sy new file mode 100644 index 0000000..3def749 --- /dev/null +++ b/Student/task3/function_test2021/001_var_defn.sy @@ -0,0 +1,7 @@ +//test global var define +int a = 3; +int b = 5; + +int main(){ + return a + b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/002_var_defn2.out b/Student/task3/function_test2021/002_var_defn2.out new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/Student/task3/function_test2021/002_var_defn2.out @@ -0,0 +1 @@ +10 diff --git a/Student/task3/function_test2021/002_var_defn2.sy b/Student/task3/function_test2021/002_var_defn2.sy new file mode 100644 index 0000000..8fdccfa --- /dev/null +++ b/Student/task3/function_test2021/002_var_defn2.sy @@ -0,0 +1,8 @@ +//test domain of global var define and local define +int a = 3; +int b = 5; + +int main(){ + int a = 5; + return a + b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/003_var_defn3.out b/Student/task3/function_test2021/003_var_defn3.out new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/Student/task3/function_test2021/003_var_defn3.out @@ -0,0 +1 @@ +5 diff --git a/Student/task3/function_test2021/003_var_defn3.sy b/Student/task3/function_test2021/003_var_defn3.sy new file mode 100644 index 0000000..192d060 --- /dev/null +++ b/Student/task3/function_test2021/003_var_defn3.sy @@ -0,0 +1,8 @@ +//test local var define +int main(){ + int a, b0, _c; + a = 1; + b0 = 2; + _c = 3; + return b0 + _c; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/004_arr_defn.out b/Student/task3/function_test2021/004_arr_defn.out new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Student/task3/function_test2021/004_arr_defn.out @@ -0,0 +1 @@ +0 diff --git a/Student/task3/function_test2021/004_arr_defn.sy b/Student/task3/function_test2021/004_arr_defn.sy new file mode 100644 index 0000000..0fa1ceb --- /dev/null +++ b/Student/task3/function_test2021/004_arr_defn.sy @@ -0,0 +1,4 @@ +int a[10]; +int main(){ + return 0; +} diff --git a/Student/task3/function_test2021/005_arr_defn2.out b/Student/task3/function_test2021/005_arr_defn2.out new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Student/task3/function_test2021/005_arr_defn2.out @@ -0,0 +1 @@ +0 diff --git a/Student/task3/function_test2021/005_arr_defn2.sy b/Student/task3/function_test2021/005_arr_defn2.sy new file mode 100644 index 0000000..fa1accd --- /dev/null +++ b/Student/task3/function_test2021/005_arr_defn2.sy @@ -0,0 +1,4 @@ +int a[10][10]; +int main(){ + return 0; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/006_arr_defn3.out b/Student/task3/function_test2021/006_arr_defn3.out new file mode 100644 index 0000000..8351c19 --- /dev/null +++ b/Student/task3/function_test2021/006_arr_defn3.out @@ -0,0 +1 @@ +14 diff --git a/Student/task3/function_test2021/006_arr_defn3.sy b/Student/task3/function_test2021/006_arr_defn3.sy new file mode 100644 index 0000000..d268998 --- /dev/null +++ b/Student/task3/function_test2021/006_arr_defn3.sy @@ -0,0 +1,9 @@ +//test array define +int main(){ + int a[4][2] = {}; + int b[4][2] = {1, 2, 3, 4, 5, 6, 7, 8}; + int c[4][2] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; + int d[4][2] = {1, 2, {3}, {5}, 7 , 8}; + int e[4][2] = {{d[2][1], c[2][1]}, {3, 4}, {5, 6}, {7, 8}}; + return e[3][1] + e[0][0] + e[0][1] + a[2][0]; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/007_arr_defn4.out b/Student/task3/function_test2021/007_arr_defn4.out new file mode 100644 index 0000000..aabe6ec --- /dev/null +++ b/Student/task3/function_test2021/007_arr_defn4.out @@ -0,0 +1 @@ +21 diff --git a/Student/task3/function_test2021/007_arr_defn4.sy b/Student/task3/function_test2021/007_arr_defn4.sy new file mode 100644 index 0000000..51a0e2c --- /dev/null +++ b/Student/task3/function_test2021/007_arr_defn4.sy @@ -0,0 +1,9 @@ +int main(){ + const int a[4][2] = {{1, 2}, {3, 4}, {}, 7}; + const int N = 3; + int b[4][2] = {}; + int c[4][2] = {1, 2, 3, 4, 5, 6, 7, 8}; + int d[N + 1][2] = {1, 2, {3}, {5}, a[3][0], 8}; + int e[4][2][1] = {{d[2][1], {c[2][1]}}, {3, 4}, {5, 6}, {7, 8}}; + return e[3][1][0] + e[0][0][0] + e[0][1][0] + d[3][0]; +} diff --git a/Student/task3/function_test2021/008_const_var_defn.out b/Student/task3/function_test2021/008_const_var_defn.out new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/Student/task3/function_test2021/008_const_var_defn.out @@ -0,0 +1 @@ +10 diff --git a/Student/task3/function_test2021/008_const_var_defn.sy b/Student/task3/function_test2021/008_const_var_defn.sy new file mode 100644 index 0000000..bfc9cf4 --- /dev/null +++ b/Student/task3/function_test2021/008_const_var_defn.sy @@ -0,0 +1,6 @@ +//test global var define +const int a = 10; + +int main(){ + return a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/009_const_var_defn2.out b/Student/task3/function_test2021/009_const_var_defn2.out new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/Student/task3/function_test2021/009_const_var_defn2.out @@ -0,0 +1 @@ +5 diff --git a/Student/task3/function_test2021/009_const_var_defn2.sy b/Student/task3/function_test2021/009_const_var_defn2.sy new file mode 100644 index 0000000..333801c --- /dev/null +++ b/Student/task3/function_test2021/009_const_var_defn2.sy @@ -0,0 +1,6 @@ +//test const gloal var define +const int a = 10, b = 5; + +int main(){ + return b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/010_const_var_defn3.out b/Student/task3/function_test2021/010_const_var_defn3.out new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/Student/task3/function_test2021/010_const_var_defn3.out @@ -0,0 +1 @@ +5 diff --git a/Student/task3/function_test2021/010_const_var_defn3.sy b/Student/task3/function_test2021/010_const_var_defn3.sy new file mode 100644 index 0000000..4dfd2e9 --- /dev/null +++ b/Student/task3/function_test2021/010_const_var_defn3.sy @@ -0,0 +1,5 @@ +//test const local var define +int main(){ + const int a = 10, b = 5; + return b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/011_const_array_defn.out b/Student/task3/function_test2021/011_const_array_defn.out new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/Student/task3/function_test2021/011_const_array_defn.out @@ -0,0 +1 @@ +4 diff --git a/Student/task3/function_test2021/011_const_array_defn.sy b/Student/task3/function_test2021/011_const_array_defn.sy new file mode 100644 index 0000000..4238a31 --- /dev/null +++ b/Student/task3/function_test2021/011_const_array_defn.sy @@ -0,0 +1,5 @@ +const int a[5]={0,1,2,3,4}; + +int main(){ + return a[4]; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/012_func_defn.out b/Student/task3/function_test2021/012_func_defn.out new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/Student/task3/function_test2021/012_func_defn.out @@ -0,0 +1 @@ +9 diff --git a/Student/task3/function_test2021/012_func_defn.sy b/Student/task3/function_test2021/012_func_defn.sy new file mode 100644 index 0000000..8b5acb2 --- /dev/null +++ b/Student/task3/function_test2021/012_func_defn.sy @@ -0,0 +1,11 @@ +int a; +int func(int p){ + p = p - 1; + return p; +} +int main(){ + int b; + a = 10; + b = func(a); + return b; +} diff --git a/Student/task3/function_test2021/013_var_defn_func.out b/Student/task3/function_test2021/013_var_defn_func.out new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/Student/task3/function_test2021/013_var_defn_func.out @@ -0,0 +1 @@ +4 diff --git a/Student/task3/function_test2021/013_var_defn_func.sy b/Student/task3/function_test2021/013_var_defn_func.sy new file mode 100644 index 0000000..03ab608 --- /dev/null +++ b/Student/task3/function_test2021/013_var_defn_func.sy @@ -0,0 +1,8 @@ +int defn(){ + return 4; +} + +int main(){ + int a=defn(); + return a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/014_add.out b/Student/task3/function_test2021/014_add.out new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/Student/task3/function_test2021/014_add.out @@ -0,0 +1 @@ +12 diff --git a/Student/task3/function_test2021/014_add.sy b/Student/task3/function_test2021/014_add.sy new file mode 100644 index 0000000..aebe726 --- /dev/null +++ b/Student/task3/function_test2021/014_add.sy @@ -0,0 +1,7 @@ +//test add +int main(){ + int a, b; + a = 10; + b = 2; + return a + b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/015_add2.out b/Student/task3/function_test2021/015_add2.out new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/Student/task3/function_test2021/015_add2.out @@ -0,0 +1 @@ +9 diff --git a/Student/task3/function_test2021/015_add2.sy b/Student/task3/function_test2021/015_add2.sy new file mode 100644 index 0000000..229ae98 --- /dev/null +++ b/Student/task3/function_test2021/015_add2.sy @@ -0,0 +1,7 @@ +//test add +int main(){ + int a, b; + a = 10; + b = -1; + return a + b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/016_addc.out b/Student/task3/function_test2021/016_addc.out new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/Student/task3/function_test2021/016_addc.out @@ -0,0 +1 @@ +15 diff --git a/Student/task3/function_test2021/016_addc.sy b/Student/task3/function_test2021/016_addc.sy new file mode 100644 index 0000000..550ed2a --- /dev/null +++ b/Student/task3/function_test2021/016_addc.sy @@ -0,0 +1,5 @@ +//test addc +const int a = 10; +int main(){ + return a + 5; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/017_sub.out b/Student/task3/function_test2021/017_sub.out new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Student/task3/function_test2021/017_sub.out @@ -0,0 +1 @@ +8 diff --git a/Student/task3/function_test2021/017_sub.sy b/Student/task3/function_test2021/017_sub.sy new file mode 100644 index 0000000..eb4ecd7 --- /dev/null +++ b/Student/task3/function_test2021/017_sub.sy @@ -0,0 +1,7 @@ +//test sub +int main(){ + int a, b; + a = 10; + b = 2; + return a - b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/018_sub2.out b/Student/task3/function_test2021/018_sub2.out new file mode 100644 index 0000000..5d0b6c4 --- /dev/null +++ b/Student/task3/function_test2021/018_sub2.out @@ -0,0 +1 @@ +248 diff --git a/Student/task3/function_test2021/018_sub2.sy b/Student/task3/function_test2021/018_sub2.sy new file mode 100644 index 0000000..54b8d5b --- /dev/null +++ b/Student/task3/function_test2021/018_sub2.sy @@ -0,0 +1,7 @@ +//test sub +const int a = 10; +int main(){ + int b; + b = 2; + return b - a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/019_subc.out b/Student/task3/function_test2021/019_subc.out new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Student/task3/function_test2021/019_subc.out @@ -0,0 +1 @@ +8 diff --git a/Student/task3/function_test2021/019_subc.sy b/Student/task3/function_test2021/019_subc.sy new file mode 100644 index 0000000..d23843b --- /dev/null +++ b/Student/task3/function_test2021/019_subc.sy @@ -0,0 +1,6 @@ +//test subc +int main(){ + int a; + a = 10; + return a - 2; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/020_mul.out b/Student/task3/function_test2021/020_mul.out new file mode 100644 index 0000000..e373ee6 --- /dev/null +++ b/Student/task3/function_test2021/020_mul.out @@ -0,0 +1 @@ +50 diff --git a/Student/task3/function_test2021/020_mul.sy b/Student/task3/function_test2021/020_mul.sy new file mode 100644 index 0000000..4d3453d --- /dev/null +++ b/Student/task3/function_test2021/020_mul.sy @@ -0,0 +1,7 @@ +//test mul +int main(){ + int a, b; + a = 10; + b = 5; + return a * b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/021_mulc.out b/Student/task3/function_test2021/021_mulc.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/021_mulc.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/021_mulc.sy b/Student/task3/function_test2021/021_mulc.sy new file mode 100644 index 0000000..b975a62 --- /dev/null +++ b/Student/task3/function_test2021/021_mulc.sy @@ -0,0 +1,5 @@ +//test mulc +const int a = 5; +int main(){ + return a * 5; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/022_div.out b/Student/task3/function_test2021/022_div.out new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/Student/task3/function_test2021/022_div.out @@ -0,0 +1 @@ +2 diff --git a/Student/task3/function_test2021/022_div.sy b/Student/task3/function_test2021/022_div.sy new file mode 100644 index 0000000..49506f3 --- /dev/null +++ b/Student/task3/function_test2021/022_div.sy @@ -0,0 +1,7 @@ +//test div +int main(){ + int a, b; + a = 10; + b = 5; + return a / b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/023_divc.out b/Student/task3/function_test2021/023_divc.out new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/Student/task3/function_test2021/023_divc.out @@ -0,0 +1 @@ +2 diff --git a/Student/task3/function_test2021/023_divc.sy b/Student/task3/function_test2021/023_divc.sy new file mode 100644 index 0000000..07505ab --- /dev/null +++ b/Student/task3/function_test2021/023_divc.sy @@ -0,0 +1,5 @@ +//test divc +const int a = 10; +int main(){ + return a / 5; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/024_mod.out b/Student/task3/function_test2021/024_mod.out new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/Student/task3/function_test2021/024_mod.out @@ -0,0 +1 @@ +3 diff --git a/Student/task3/function_test2021/024_mod.sy b/Student/task3/function_test2021/024_mod.sy new file mode 100644 index 0000000..b186545 --- /dev/null +++ b/Student/task3/function_test2021/024_mod.sy @@ -0,0 +1,6 @@ +//test mod +int main(){ + int a; + a = 10; + return a / 3; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/025_rem.out b/Student/task3/function_test2021/025_rem.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Student/task3/function_test2021/025_rem.out @@ -0,0 +1 @@ +1 diff --git a/Student/task3/function_test2021/025_rem.sy b/Student/task3/function_test2021/025_rem.sy new file mode 100644 index 0000000..6aa8143 --- /dev/null +++ b/Student/task3/function_test2021/025_rem.sy @@ -0,0 +1,6 @@ +//test rem +int main(){ + int a; + a = 10; + return a % 3; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/026_if.out b/Student/task3/function_test2021/026_if.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Student/task3/function_test2021/026_if.out @@ -0,0 +1 @@ +1 diff --git a/Student/task3/function_test2021/026_if.sy b/Student/task3/function_test2021/026_if.sy new file mode 100644 index 0000000..a908d63 --- /dev/null +++ b/Student/task3/function_test2021/026_if.sy @@ -0,0 +1,9 @@ +int a; + +int main(){ + a = 10; + if( a>0 ){ + return 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/027_if2.out b/Student/task3/function_test2021/027_if2.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Student/task3/function_test2021/027_if2.out @@ -0,0 +1 @@ +1 diff --git a/Student/task3/function_test2021/027_if2.sy b/Student/task3/function_test2021/027_if2.sy new file mode 100644 index 0000000..a4f5062 --- /dev/null +++ b/Student/task3/function_test2021/027_if2.sy @@ -0,0 +1,10 @@ +int a; +int main(){ + a = 10; + if( a>0 ){ + return 1; + } + else{ + return 0; + } +} diff --git a/Student/task3/function_test2021/028_if_test1.out b/Student/task3/function_test2021/028_if_test1.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/028_if_test1.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/028_if_test1.sy b/Student/task3/function_test2021/028_if_test1.sy new file mode 100644 index 0000000..1811e94 --- /dev/null +++ b/Student/task3/function_test2021/028_if_test1.sy @@ -0,0 +1,16 @@ +// test if-else +int ifElse() { + int a; + a = 5; + if (a == 5) { + a = 25; + } else { + a = a * 2; + } + return (a); +} + + +int main() { + return (ifElse()); +} diff --git a/Student/task3/function_test2021/029_if_test2.out b/Student/task3/function_test2021/029_if_test2.out new file mode 100644 index 0000000..330e18d --- /dev/null +++ b/Student/task3/function_test2021/029_if_test2.out @@ -0,0 +1,2 @@ +-5 +0 diff --git a/Student/task3/function_test2021/029_if_test2.sy b/Student/task3/function_test2021/029_if_test2.sy new file mode 100644 index 0000000..bf7b8fa --- /dev/null +++ b/Student/task3/function_test2021/029_if_test2.sy @@ -0,0 +1,25 @@ +// test if-else-if +int ifElseIf() { + int a; + a = 5; + int b; + b = 10; + if(a == 6 || b == 0xb) { + return a; + } + else { + if (b == 10 && a == 1) + a = 25; + else if (b == 10 && a == -5) + a = a + 15; + else + a = -+a; + } + + return a; +} + +int main(){ + putint(ifElseIf()); + return 0; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/030_if_test3.out b/Student/task3/function_test2021/030_if_test3.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/030_if_test3.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/030_if_test3.sy b/Student/task3/function_test2021/030_if_test3.sy new file mode 100644 index 0000000..7f48df1 --- /dev/null +++ b/Student/task3/function_test2021/030_if_test3.sy @@ -0,0 +1,18 @@ +// test if-if-else +int ififElse() { + int a; + a = 5; + int b; + b = 10; + if(a == 5) + if (b == 10) + a = 25; + else + a = a + 15; + + return (a); +} + +int main(){ + return (ififElse()); +} diff --git a/Student/task3/function_test2021/031_if_test4.out b/Student/task3/function_test2021/031_if_test4.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/031_if_test4.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/031_if_test4.sy b/Student/task3/function_test2021/031_if_test4.sy new file mode 100644 index 0000000..fb01502 --- /dev/null +++ b/Student/task3/function_test2021/031_if_test4.sy @@ -0,0 +1,18 @@ +// test if-{if-else} +int if_ifElse_() { + int a; + a = 5; + int b; + b = 10; + if(a == 5){ + if (b == 10) + a = 25; + else + a = a + 15; + } + return (a); +} + +int main(){ + return (if_ifElse_()); +} diff --git a/Student/task3/function_test2021/032_if_test5.out b/Student/task3/function_test2021/032_if_test5.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/032_if_test5.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/032_if_test5.sy b/Student/task3/function_test2021/032_if_test5.sy new file mode 100644 index 0000000..39cf890 --- /dev/null +++ b/Student/task3/function_test2021/032_if_test5.sy @@ -0,0 +1,18 @@ +// test if-{if}-else +int if_if_Else() { + int a; + a = 5; + int b; + b = 10; + if(a == 5){ + if (b == 10) + a = 25; + } + else + a = a + 15; + return (a); +} + +int main(){ + return (if_if_Else()); +} diff --git a/Student/task3/function_test2021/033_while_if.out b/Student/task3/function_test2021/033_while_if.out new file mode 100644 index 0000000..abe17ac --- /dev/null +++ b/Student/task3/function_test2021/033_while_if.out @@ -0,0 +1,2 @@ +88 +0 diff --git a/Student/task3/function_test2021/033_while_if.sy b/Student/task3/function_test2021/033_while_if.sy new file mode 100644 index 0000000..47b8b79 --- /dev/null +++ b/Student/task3/function_test2021/033_while_if.sy @@ -0,0 +1,31 @@ +int get_one(int a) { + return 1; +} + +int deepWhileBr(int a, int b) { + int c; + c = a + b; + while (c < 75) { + int d; + d = 42; + if (c < 100) { + c = c + d; + if (c > 99) { + int e; + e = d * 2; + if (get_one(0) == 1) { + c = e * 2; + } + } + } + } + return (c); +} + +int main() { + int p; + p = 2; + p = deepWhileBr(p, p); + putint(p); + return 0; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/034_while_test1.out b/Student/task3/function_test2021/034_while_test1.out new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/Student/task3/function_test2021/034_while_test1.out @@ -0,0 +1 @@ +3 diff --git a/Student/task3/function_test2021/034_while_test1.sy b/Student/task3/function_test2021/034_while_test1.sy new file mode 100644 index 0000000..d184d5b --- /dev/null +++ b/Student/task3/function_test2021/034_while_test1.sy @@ -0,0 +1,18 @@ +int doubleWhile() { + int i; + i = 5; + int j; + j = 7; + while (i < 100) { + i = i + 30; + while(j < 100){ + j = j + 6; + } + j = j - 100; + } + return (j); +} + +int main() { + return doubleWhile(); +} diff --git a/Student/task3/function_test2021/035_while_test2.out b/Student/task3/function_test2021/035_while_test2.out new file mode 100644 index 0000000..fb1e7bc --- /dev/null +++ b/Student/task3/function_test2021/035_while_test2.out @@ -0,0 +1 @@ +54 diff --git a/Student/task3/function_test2021/035_while_test2.sy b/Student/task3/function_test2021/035_while_test2.sy new file mode 100644 index 0000000..d1fad82 --- /dev/null +++ b/Student/task3/function_test2021/035_while_test2.sy @@ -0,0 +1,31 @@ +int FourWhile() { + int a; + a = 5; + int b; + int c; + b = 6; + c = 7; + int d; + d = 10; + while (a < 20) { + a = a + 3; + while(b < 10){ + b = b + 1; + while(c == 7){ + c = c - 1; + while(d < 20){ + d = d + 3; + } + d = d - 1; + } + c = c + 1; + } + b = b - 2; + } + + return (a + (b + d) + c); +} + +int main() { + return FourWhile(); +} diff --git a/Student/task3/function_test2021/036_while_test3.out b/Student/task3/function_test2021/036_while_test3.out new file mode 100644 index 0000000..4099407 --- /dev/null +++ b/Student/task3/function_test2021/036_while_test3.out @@ -0,0 +1 @@ +23 diff --git a/Student/task3/function_test2021/036_while_test3.sy b/Student/task3/function_test2021/036_while_test3.sy new file mode 100644 index 0000000..47ffb5f --- /dev/null +++ b/Student/task3/function_test2021/036_while_test3.sy @@ -0,0 +1,55 @@ +int g; +int h; +int f; +int e; +int EightWhile() { + int a; + a = 5; + int b; + int c; + b = 6; + c = 7; + int d; + d = 10; + while (a < 20) { + a = a + 3; + while(b < 10){ + b = b + 1; + while(c == 7){ + c = c - 1; + while(d < 20){ + d = d + 3; + while(e > 1){ + e = e-1; + while(f > 2){ + f = f -2; + while(g < 3){ + g = g +10; + while(h < 10){ + h = h + 8; + } + h = h-1; + } + g = g- 8; + } + f = f + 1; + } + e = e + 1; + } + d = d - 1; + } + c = c + 1; + } + b = b - 2; + } + + return (a + (b + d) + c)-(e + d - g + h); +} + +int main() { + g = 1; + h = 2; + e = 4; + f = 6; + return EightWhile(); +} diff --git a/Student/task3/function_test2021/037_break.out b/Student/task3/function_test2021/037_break.out new file mode 100644 index 0000000..3bc92d4 --- /dev/null +++ b/Student/task3/function_test2021/037_break.out @@ -0,0 +1 @@ +201 diff --git a/Student/task3/function_test2021/037_break.sy b/Student/task3/function_test2021/037_break.sy new file mode 100644 index 0000000..2ab2a05 --- /dev/null +++ b/Student/task3/function_test2021/037_break.sy @@ -0,0 +1,15 @@ +//test break +int main(){ + int i; + i = 0; + int sum; + sum = 0; + while(i < 100){ + if(i == 50){ + break; + } + sum = sum + i; + i = i + 1; + } + return sum; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/038_continue.out b/Student/task3/function_test2021/038_continue.out new file mode 100644 index 0000000..7facc89 --- /dev/null +++ b/Student/task3/function_test2021/038_continue.out @@ -0,0 +1 @@ +36 diff --git a/Student/task3/function_test2021/038_continue.sy b/Student/task3/function_test2021/038_continue.sy new file mode 100644 index 0000000..b20cd55 --- /dev/null +++ b/Student/task3/function_test2021/038_continue.sy @@ -0,0 +1,16 @@ +//test continue +int main(){ + int i; + i = 0; + int sum; + sum = 0; + while(i < 100){ + if(i == 50){ + i = i + 1; + continue; + } + sum = sum + i; + i = i + 1; + } + return sum; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/039_while_if_test1.out b/Student/task3/function_test2021/039_while_if_test1.out new file mode 100644 index 0000000..ca55a6c --- /dev/null +++ b/Student/task3/function_test2021/039_while_if_test1.out @@ -0,0 +1 @@ +198 diff --git a/Student/task3/function_test2021/039_while_if_test1.sy b/Student/task3/function_test2021/039_while_if_test1.sy new file mode 100644 index 0000000..2d2b9fb --- /dev/null +++ b/Student/task3/function_test2021/039_while_if_test1.sy @@ -0,0 +1,25 @@ +// test while-if +int whileIf() { + int a; + a = 0; + int b; + b = 0; + while (a < 100) { + if (a == 5) { + b = 25; + } + else if (a == 10) { + b = 42; + } + else { + b = a * 2; + } + a = a + 1; + } + return (b); +} + + +int main(){ + return (whileIf()); +} diff --git a/Student/task3/function_test2021/040_while_if_test2.out b/Student/task3/function_test2021/040_while_if_test2.out new file mode 100644 index 0000000..f906e18 --- /dev/null +++ b/Student/task3/function_test2021/040_while_if_test2.out @@ -0,0 +1 @@ +96 diff --git a/Student/task3/function_test2021/040_while_if_test2.sy b/Student/task3/function_test2021/040_while_if_test2.sy new file mode 100644 index 0000000..34c92da --- /dev/null +++ b/Student/task3/function_test2021/040_while_if_test2.sy @@ -0,0 +1,23 @@ +int ifWhile() { + int a; + a = 0; + int b; + b = 3; + if (a == 5) { + while(b == 2){ + b = b + 2; + } + b = b + 25; + } + else + while (a < 5) { + b = b * 2; + a = a + 1; + } + return (b); +} + + +int main(){ + return (ifWhile()); +} diff --git a/Student/task3/function_test2021/041_while_if_test3.out b/Student/task3/function_test2021/041_while_if_test3.out new file mode 100644 index 0000000..d22307c --- /dev/null +++ b/Student/task3/function_test2021/041_while_if_test3.out @@ -0,0 +1 @@ +88 diff --git a/Student/task3/function_test2021/041_while_if_test3.sy b/Student/task3/function_test2021/041_while_if_test3.sy new file mode 100644 index 0000000..ef16dfa --- /dev/null +++ b/Student/task3/function_test2021/041_while_if_test3.sy @@ -0,0 +1,25 @@ +int deepWhileBr(int a, int b) { + int c; + c = a + b; + while (c < 75) { + int d; + d = 42; + if (c < 100) { + c = c + d; + if (c > 99) { + int e; + e = d * 2; + if (1 == 1) { + c = e * 2; + } + } + } + } + return (c); +} + +int main() { + int p; + p = 2; + return deepWhileBr(p, p); +} diff --git a/Student/task3/function_test2021/042_arr_expr_len.out b/Student/task3/function_test2021/042_arr_expr_len.out new file mode 100644 index 0000000..82cced2 --- /dev/null +++ b/Student/task3/function_test2021/042_arr_expr_len.out @@ -0,0 +1 @@ +51 diff --git a/Student/task3/function_test2021/042_arr_expr_len.sy b/Student/task3/function_test2021/042_arr_expr_len.sy new file mode 100644 index 0000000..391776e --- /dev/null +++ b/Student/task3/function_test2021/042_arr_expr_len.sy @@ -0,0 +1,11 @@ +const int N = -1; +int arr[N + 2 * 4 - 99 / 99] = {1, 2, 33, 4, 5, 6}; + +int main() { + int i = 0, sum = 0; + while (i < 6) { + sum = sum + arr[i]; + i = i + 1; + } + return sum; +} diff --git a/Student/task3/function_test2021/043_op_priority1.out b/Student/task3/function_test2021/043_op_priority1.out new file mode 100644 index 0000000..425151f --- /dev/null +++ b/Student/task3/function_test2021/043_op_priority1.out @@ -0,0 +1 @@ +40 diff --git a/Student/task3/function_test2021/043_op_priority1.sy b/Student/task3/function_test2021/043_op_priority1.sy new file mode 100644 index 0000000..2d745b2 --- /dev/null +++ b/Student/task3/function_test2021/043_op_priority1.sy @@ -0,0 +1,9 @@ +//test the priority of add and mul +int main(){ + int a, b, c, d; + a = 10; + b = 4; + c = 2; + d = 2; + return c + a * b - d; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/044_op_priority2.out b/Student/task3/function_test2021/044_op_priority2.out new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/Student/task3/function_test2021/044_op_priority2.out @@ -0,0 +1 @@ +24 diff --git a/Student/task3/function_test2021/044_op_priority2.sy b/Student/task3/function_test2021/044_op_priority2.sy new file mode 100644 index 0000000..ac9c015 --- /dev/null +++ b/Student/task3/function_test2021/044_op_priority2.sy @@ -0,0 +1,9 @@ +//test the priority of add and mul +int main(){ + int a, b, c, d; + a = 10; + b = 4; + c = 2; + d = 2; + return (c + a) * (b - d); +} \ No newline at end of file diff --git a/Student/task3/function_test2021/045_op_priority3.out b/Student/task3/function_test2021/045_op_priority3.out new file mode 100644 index 0000000..425151f --- /dev/null +++ b/Student/task3/function_test2021/045_op_priority3.out @@ -0,0 +1 @@ +40 diff --git a/Student/task3/function_test2021/045_op_priority3.sy b/Student/task3/function_test2021/045_op_priority3.sy new file mode 100644 index 0000000..e04c930 --- /dev/null +++ b/Student/task3/function_test2021/045_op_priority3.sy @@ -0,0 +1,7 @@ +//test the priority of unary operator and binary operator +int main(){ + int a, b; + a = 10; + b = 30; + return a - -5 + b + -5; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/046_op_priority4.in b/Student/task3/function_test2021/046_op_priority4.in new file mode 100644 index 0000000..ecfbc7c --- /dev/null +++ b/Student/task3/function_test2021/046_op_priority4.in @@ -0,0 +1 @@ +0 1 1 1 1 diff --git a/Student/task3/function_test2021/046_op_priority4.out b/Student/task3/function_test2021/046_op_priority4.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Student/task3/function_test2021/046_op_priority4.out @@ -0,0 +1 @@ +1 diff --git a/Student/task3/function_test2021/046_op_priority4.sy b/Student/task3/function_test2021/046_op_priority4.sy new file mode 100644 index 0000000..6246557 --- /dev/null +++ b/Student/task3/function_test2021/046_op_priority4.sy @@ -0,0 +1,19 @@ +int a; +int b; +int c; +int d; +int e; +int main() +{ + a=getint(); + b=getint(); + c=getint(); + d=getint(); + e=getint(); + int flag=0; + if(a-b*c!=d-a/c||a*b/c==e+d||a+b+c==d+e) + { + flag=1; + } + return flag; +} diff --git a/Student/task3/function_test2021/047_op_priority5.out b/Student/task3/function_test2021/047_op_priority5.out new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/Student/task3/function_test2021/047_op_priority5.out @@ -0,0 +1,2 @@ +1 +1 diff --git a/Student/task3/function_test2021/047_op_priority5.sy b/Student/task3/function_test2021/047_op_priority5.sy new file mode 100644 index 0000000..ac787fc --- /dev/null +++ b/Student/task3/function_test2021/047_op_priority5.sy @@ -0,0 +1,15 @@ +int a = 1; +int b = 0; +int c = 1; +int d = 2; +int e = 4; +int main() +{ + int flag=0; + if(a * b / c == e + d && a * (a + b) + c <= d + e || a - (b * c) == d - a / c) + { + flag=1; + } + putint(flag); + return flag; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/048_stmt_expr.out b/Student/task3/function_test2021/048_stmt_expr.out new file mode 100644 index 0000000..670473d --- /dev/null +++ b/Student/task3/function_test2021/048_stmt_expr.out @@ -0,0 +1,2 @@ +1024 +0 diff --git a/Student/task3/function_test2021/048_stmt_expr.sy b/Student/task3/function_test2021/048_stmt_expr.sy new file mode 100644 index 0000000..a5f5bb5 --- /dev/null +++ b/Student/task3/function_test2021/048_stmt_expr.sy @@ -0,0 +1,13 @@ +int k; +const int n = 10; +int main () { + int i = 0; + k = 1; + while (i <= n - 1) { + i = i + 1; + k + 1; + k = k + k; + } + putint(k); + return k; +} diff --git a/Student/task3/function_test2021/049_unary_op.out b/Student/task3/function_test2021/049_unary_op.out new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Student/task3/function_test2021/049_unary_op.out @@ -0,0 +1 @@ +0 diff --git a/Student/task3/function_test2021/049_unary_op.sy b/Student/task3/function_test2021/049_unary_op.sy new file mode 100644 index 0000000..eb5e28c --- /dev/null +++ b/Student/task3/function_test2021/049_unary_op.sy @@ -0,0 +1,11 @@ +int main() { + int a; + a = 10; + if (+-!!!a) { + a = - - -1; + } + else { + a = 0; + } + return a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/050_unary_op2.out b/Student/task3/function_test2021/050_unary_op2.out new file mode 100644 index 0000000..661d826 --- /dev/null +++ b/Student/task3/function_test2021/050_unary_op2.out @@ -0,0 +1,2 @@ +4 +0 diff --git a/Student/task3/function_test2021/050_unary_op2.sy b/Student/task3/function_test2021/050_unary_op2.sy new file mode 100644 index 0000000..a824266 --- /dev/null +++ b/Student/task3/function_test2021/050_unary_op2.sy @@ -0,0 +1,14 @@ +int main() { + int a, b; + a = 070; + b = 0x4; + a = a - - 4 + + b; + if (+-!!!a) { + a = - - -1; + } + else { + a = 0 + + b; + } + putint(a); + return 0; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/051_logi_assign.in b/Student/task3/function_test2021/051_logi_assign.in new file mode 100644 index 0000000..8835c07 --- /dev/null +++ b/Student/task3/function_test2021/051_logi_assign.in @@ -0,0 +1 @@ +4 4 diff --git a/Student/task3/function_test2021/051_logi_assign.out b/Student/task3/function_test2021/051_logi_assign.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Student/task3/function_test2021/051_logi_assign.out @@ -0,0 +1 @@ +1 diff --git a/Student/task3/function_test2021/051_logi_assign.sy b/Student/task3/function_test2021/051_logi_assign.sy new file mode 100644 index 0000000..dd96553 --- /dev/null +++ b/Student/task3/function_test2021/051_logi_assign.sy @@ -0,0 +1,15 @@ +int a; +int b; +int main() +{ + a=getint(); + b=getint(); + int c; + if (a==b&&a!=3) { + c = 1; + } + else { + c = 0; + } + return c; +} diff --git a/Student/task3/function_test2021/052_comment1.out b/Student/task3/function_test2021/052_comment1.out new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/Student/task3/function_test2021/052_comment1.out @@ -0,0 +1 @@ +5 diff --git a/Student/task3/function_test2021/052_comment1.sy b/Student/task3/function_test2021/052_comment1.sy new file mode 100644 index 0000000..d14c157 --- /dev/null +++ b/Student/task3/function_test2021/052_comment1.sy @@ -0,0 +1,8 @@ +//test comment +int main(){ + int a; + a = 5; + //int b = 4; + //a = b + a; + return a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/053_comment2.out b/Student/task3/function_test2021/053_comment2.out new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/Student/task3/function_test2021/053_comment2.out @@ -0,0 +1 @@ +2 diff --git a/Student/task3/function_test2021/053_comment2.sy b/Student/task3/function_test2021/053_comment2.sy new file mode 100644 index 0000000..fa2438a --- /dev/null +++ b/Student/task3/function_test2021/053_comment2.sy @@ -0,0 +1,11 @@ +//test comment +int main(){ + int a, b; + a = 10; + b = 2; + /*/* + b = 1; + // b = 2 + */ + return b; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/054_hex_defn.out b/Student/task3/function_test2021/054_hex_defn.out new file mode 100644 index 0000000..60d3b2f --- /dev/null +++ b/Student/task3/function_test2021/054_hex_defn.out @@ -0,0 +1 @@ +15 diff --git a/Student/task3/function_test2021/054_hex_defn.sy b/Student/task3/function_test2021/054_hex_defn.sy new file mode 100644 index 0000000..3f20fdf --- /dev/null +++ b/Student/task3/function_test2021/054_hex_defn.sy @@ -0,0 +1,6 @@ +// test hexadecimal define +int main(){ + int a; + a = 0xf; + return a; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/055_hex_oct_add.out b/Student/task3/function_test2021/055_hex_oct_add.out new file mode 100644 index 0000000..d22307c --- /dev/null +++ b/Student/task3/function_test2021/055_hex_oct_add.out @@ -0,0 +1 @@ +88 diff --git a/Student/task3/function_test2021/055_hex_oct_add.sy b/Student/task3/function_test2021/055_hex_oct_add.sy new file mode 100644 index 0000000..545a8cd --- /dev/null +++ b/Student/task3/function_test2021/055_hex_oct_add.sy @@ -0,0 +1,7 @@ +//test add of hex and oct +int main(){ + int a, b; + a = 0xf; + b = 0xc; + return a + b + 075; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/056_assign_complex_expr.out b/Student/task3/function_test2021/056_assign_complex_expr.out new file mode 100644 index 0000000..d0890d1 --- /dev/null +++ b/Student/task3/function_test2021/056_assign_complex_expr.out @@ -0,0 +1,2 @@ +-171 +0 diff --git a/Student/task3/function_test2021/056_assign_complex_expr.sy b/Student/task3/function_test2021/056_assign_complex_expr.sy new file mode 100644 index 0000000..c6471a7 --- /dev/null +++ b/Student/task3/function_test2021/056_assign_complex_expr.sy @@ -0,0 +1,18 @@ +// Use complex expression in assign structure +int main () { + int a; + int b; + int c; + int d; + int result; + a = 5; + b = 5; + c = 1; + d = -2; + result = (d * 1 / 2) + (a - b) - -(c + 3) % 2; + putint(result); + result = ((d % 2 + 67) + -(a - b) - -((c + 2) % 2)); + result = result + 3; + putint(result); + return 0; +} diff --git a/Student/task3/function_test2021/057_if_complex_expr.out b/Student/task3/function_test2021/057_if_complex_expr.out new file mode 100644 index 0000000..389e262 --- /dev/null +++ b/Student/task3/function_test2021/057_if_complex_expr.out @@ -0,0 +1,2 @@ +2 +0 diff --git a/Student/task3/function_test2021/057_if_complex_expr.sy b/Student/task3/function_test2021/057_if_complex_expr.sy new file mode 100644 index 0000000..32c897c --- /dev/null +++ b/Student/task3/function_test2021/057_if_complex_expr.sy @@ -0,0 +1,21 @@ +// Use complex expression in if structure +int main () { + int a; + int b; + int c; + int d; + int result; + a = 5; + b = 5; + c = 1; + d = -2; + result = 2; + if ((d * 1 / 2) < 0 || (a - b) != 0 && (c + 3) % 2 != 0) { + putint(result); + } + if ((d % 2 + 67) < 0 || (a - b) != 0 && (c + 2) % 2 != 0) { + result = 4; + putint(result); + } + return 0; +} diff --git a/Student/task3/function_test2021/058_short_circuit.in b/Student/task3/function_test2021/058_short_circuit.in new file mode 100644 index 0000000..71f0f6a --- /dev/null +++ b/Student/task3/function_test2021/058_short_circuit.in @@ -0,0 +1,4 @@ +11 +10 +100 +99 \ No newline at end of file diff --git a/Student/task3/function_test2021/058_short_circuit.out b/Student/task3/function_test2021/058_short_circuit.out new file mode 100644 index 0000000..882e4db --- /dev/null +++ b/Student/task3/function_test2021/058_short_circuit.out @@ -0,0 +1,2 @@ +11111210 +0 diff --git a/Student/task3/function_test2021/058_short_circuit.sy b/Student/task3/function_test2021/058_short_circuit.sy new file mode 100644 index 0000000..322855d --- /dev/null +++ b/Student/task3/function_test2021/058_short_circuit.sy @@ -0,0 +1,21 @@ +int g = 0; + +int func(int n) { + g = g + n; + putint(g); + return g; +} + +int main() { + int i; + i = getint(); + if (i > 10 && func(i)) i = 1; else i = 0; + i = getint(); + if (i > 11 && func(i)) i = 1; else i = 0; + i = getint(); + if (i <= 99 || func(i)) i = 1; else i = 0; + i = getint(); + if (i <= 100 || func(i)) i = 1; else i = 0; + if (!func(99) && func(100)) i = 1; else i = 0; + return 0; +} diff --git a/Student/task3/function_test2021/059_short_circuit2.out b/Student/task3/function_test2021/059_short_circuit2.out new file mode 100644 index 0000000..911faf0 --- /dev/null +++ b/Student/task3/function_test2021/059_short_circuit2.out @@ -0,0 +1,2 @@ +05040 +0 diff --git a/Student/task3/function_test2021/059_short_circuit2.sy b/Student/task3/function_test2021/059_short_circuit2.sy new file mode 100644 index 0000000..7dbfca0 --- /dev/null +++ b/Student/task3/function_test2021/059_short_circuit2.sy @@ -0,0 +1,26 @@ +int func(int n) { + if (n <= 50) { + putint(n); + return 1; + } + else { + putint(n); + return 0; + } +} + +int main() { + int i; + + if (func(0) == 1 || func(50) == 1 && func(100) == 0) + i = 0; + else + i = 1; + + if (func(50) == 1 && func(40) == 1 || func(1) == 1 ) + i = 0; + else + i = 1; + + return 0; +} diff --git a/Student/task3/function_test2021/060_scope.out b/Student/task3/function_test2021/060_scope.out new file mode 100644 index 0000000..b261da1 --- /dev/null +++ b/Student/task3/function_test2021/060_scope.out @@ -0,0 +1,2 @@ +1 +0 diff --git a/Student/task3/function_test2021/060_scope.sy b/Student/task3/function_test2021/060_scope.sy new file mode 100644 index 0000000..7be1453 --- /dev/null +++ b/Student/task3/function_test2021/060_scope.sy @@ -0,0 +1,27 @@ +int a = 7; + +int func() { + int b = a; + int a = 1; + if (a == b) { + a = a + 1; + return 1; + } + else + return 0; +} + +int main() { + int result = 0; + int i = 0; + while (i < 100) { + if (func() == 1) + result = result + 1; + i = i + 1; + } + if (result < 100) + putint(1); + else + putint(0); + return 0; +} diff --git a/Student/task3/function_test2021/061_sort_test1.out b/Student/task3/function_test2021/061_sort_test1.out new file mode 100644 index 0000000..c9f2be1 --- /dev/null +++ b/Student/task3/function_test2021/061_sort_test1.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 diff --git a/Student/task3/function_test2021/061_sort_test1.sy b/Student/task3/function_test2021/061_sort_test1.sy new file mode 100644 index 0000000..8491e90 --- /dev/null +++ b/Student/task3/function_test2021/061_sort_test1.sy @@ -0,0 +1,41 @@ +int n; +int bubblesort(int arr[]) +{ + int i; + int j; + i =0; + while(i < n-1){ + // Last i elements are already in place + j = 0; + while(j < n-i-1){ + if (arr[j] > arr[j+1]) { + // swap(&arr[j], &arr[j+1]); + int tmp; + tmp = arr[j+1]; + arr[j+1] = arr[j]; + arr[j] = tmp; + } + j = j + 1; + } + i = i + 1; + } + return 0; +} + +int main(){ + n = 10; + int a[10]; + a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0; + a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8; + int i; + i = bubblesort(a); + while (i < n) { + int tmp; + tmp = a[i]; + putint(tmp); + tmp = 10; + putch(tmp); + i = i + 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/062_sort_test2.out b/Student/task3/function_test2021/062_sort_test2.out new file mode 100644 index 0000000..c9f2be1 --- /dev/null +++ b/Student/task3/function_test2021/062_sort_test2.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 diff --git a/Student/task3/function_test2021/062_sort_test2.sy b/Student/task3/function_test2021/062_sort_test2.sy new file mode 100644 index 0000000..8ec1764 --- /dev/null +++ b/Student/task3/function_test2021/062_sort_test2.sy @@ -0,0 +1,39 @@ +int n; +int insertsort(int a[]) +{ + int i; + i = 1; + while(i-1&&temp k - 1) + { + j = j - 1; + } + + if(i < j) + { + arr[i] = arr[j]; + i = i + 1; + } + + while(i < j && arr[i] < k) + { + i = i + 1; + } + + if(i < j) + { + arr[j] = arr[i]; + j = j - 1; + } + } + + arr[i] = k; + int tmp; + tmp = i - 1; + tmp = QuickSort(arr, low, tmp); + tmp = i + 1; + tmp = QuickSort(arr, tmp, high); + } + return 0; +} + +int main(){ + n = 10; + int a[10]; + a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0; + a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8; + int i; + i = 0; + int tmp; + tmp = 9; + i = QuickSort(a, i, tmp); + while (i < n) { + int tmp; + tmp = a[i]; + putint(tmp); + tmp = 10; + putch(tmp); + i = i + 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/064_sort_test4.out b/Student/task3/function_test2021/064_sort_test4.out new file mode 100644 index 0000000..c9f2be1 --- /dev/null +++ b/Student/task3/function_test2021/064_sort_test4.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 diff --git a/Student/task3/function_test2021/064_sort_test4.sy b/Student/task3/function_test2021/064_sort_test4.sy new file mode 100644 index 0000000..9280cd1 --- /dev/null +++ b/Student/task3/function_test2021/064_sort_test4.sy @@ -0,0 +1,49 @@ +int n; +int select_sort(int A[],int n) +{ + int i; + int j; + int min; + i =0; + while(i < n-1) + { + min=i;// + j = i + 1; + while(j < n) + { + if(A[min]>A[j]) + { + min=j; + } + j=j+1; + } + if(min!=i) + { + int tmp; + tmp = A[min]; + A[min] = A[i]; + A[i] = tmp; + } + i = i + 1; + } + return 0; +} + +int main(){ + n = 10; + int a[10]; + a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0; + a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8; + int i; + i = 0; + i = select_sort(a, n); + while (i < n) { + int tmp; + tmp = a[i]; + putint(tmp); + tmp = 10; + putch(tmp); + i = i + 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/065_sort_test5.out b/Student/task3/function_test2021/065_sort_test5.out new file mode 100644 index 0000000..c9f2be1 --- /dev/null +++ b/Student/task3/function_test2021/065_sort_test5.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 diff --git a/Student/task3/function_test2021/065_sort_test5.sy b/Student/task3/function_test2021/065_sort_test5.sy new file mode 100644 index 0000000..6c634e5 --- /dev/null +++ b/Student/task3/function_test2021/065_sort_test5.sy @@ -0,0 +1,65 @@ +int n; +int swap (int array[], int i, int j){ + int temp; + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + return 0; +} +int heap_ajust(int arr[], int start, int end) { + int dad; + dad = start; + int son; + son = dad * 2 + 1; + while (son < end + 1) { // + if (son < end && arr[son] < arr[son + 1]) + son = son + 1; + if (arr[dad] > arr[son]) + return 0; + else { + dad = swap(arr,dad,son); + dad = son; + son = dad * 2 + 1; + } + } + return 0; +} +int heap_sort(int arr[], int len) { + int i; + int tmp; + i = len / 2 - 1; + while ( i > -1) { + tmp = len - 1; + tmp = heap_ajust(arr, i, tmp); + i = i - 1; + } + i = len - 1; + while ( i > 0) { + int tmp0; + tmp0 = 0; + tmp = swap(arr,tmp0,i); + tmp = i - 1; + tmp = heap_ajust(arr, tmp0, tmp); + i = i-1; + } + return 0; +} + +int main(){ + n = 10; + int a[10]; + a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0; + a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8; + int i; + i = 0; + i = heap_sort(a, n); + while (i < n) { + int tmp; + tmp = a[i]; + putint(tmp); + tmp = 10; + putch(tmp); + i = i + 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/066_sort_test6.out b/Student/task3/function_test2021/066_sort_test6.out new file mode 100644 index 0000000..c9f2be1 --- /dev/null +++ b/Student/task3/function_test2021/066_sort_test6.out @@ -0,0 +1,11 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0 diff --git a/Student/task3/function_test2021/066_sort_test6.sy b/Student/task3/function_test2021/066_sort_test6.sy new file mode 100644 index 0000000..24093c7 --- /dev/null +++ b/Student/task3/function_test2021/066_sort_test6.sy @@ -0,0 +1,53 @@ +int n; + +int counting_sort(int ini_arr[], int sorted_arr[], int n) { + int count_arr[10]; + int i; + int j; + int k; + k = 0; + i = 0; + j = 0; + while(k < 10){ + count_arr[k] = 0; + k = k + 1; + } + while(i < n) + { + count_arr[ini_arr[i]] = count_arr[ini_arr[i]] + 1; + i = i + 1; + } + k = 1; + while(k < 10){ + count_arr[k] = count_arr[k] + count_arr[k - 1]; + k = k + 1; + } + j = n; + while( j > 0){ + count_arr[ini_arr[j - 1]] = count_arr[ini_arr[j - 1]] - 1; + sorted_arr[count_arr[ini_arr[j - 1]]] = ini_arr[j - 1]; + j = j - 1; + } + return 0; +} + + +int main(){ + n = 10; + int a[10]; + a[0]=4;a[1]=3;a[2]=9;a[3]=2;a[4]=0; + a[5]=1;a[6]=6;a[7]=5;a[8]=7;a[9]=8; + int i; + i = 0; + int b[10]; + i = counting_sort(a, b, n); + while (i < n) { + int tmp; + tmp = b[i]; + putint(tmp); + tmp = 10; + putch(tmp); + i = i + 1; + } + return 0; +} diff --git a/Student/task3/function_test2021/067_sort_test7.in b/Student/task3/function_test2021/067_sort_test7.in new file mode 100644 index 0000000..623bd2a --- /dev/null +++ b/Student/task3/function_test2021/067_sort_test7.in @@ -0,0 +1,11 @@ +97 +-10525 -9882 48155 -22162 -38879 52218 -44913 14799 -52541 19859 + 23040 38767 -39850 -2221 -63865 51868 64903 -3812 -58581 -14684 +-29113 12117 -32032 -58451 -59283 -24783 -10753 -18185 28370 7266 + 760 30956 -35818 -52888 -37486 21562 14967 53534 46231 -46019 +-46994 -62145 24886 18009 63111 -14203 40779 51479 36163 14992 + 57399 -58381 5335 -38236 4245 -33049 33608 -63687 37320 -32676 + 6602 40444 1715 11292 2406 16023 1996 -60066 -52763 -16559 + 53676 22077 57606 46802 -2033 -64412 -58092 61266 59389 -38805 + 1155 59786 35700 52562 9161 -2723 -57451 46501 -2730 38395 + -2556 -38481 52802 -47314 -21799 -18640 60818 diff --git a/Student/task3/function_test2021/067_sort_test7.out b/Student/task3/function_test2021/067_sort_test7.out new file mode 100644 index 0000000..9edc34d --- /dev/null +++ b/Student/task3/function_test2021/067_sort_test7.out @@ -0,0 +1,2 @@ +97: -64412 -63865 -63687 -62145 -60066 -59283 -58581 -58451 -58381 -58092 -57451 -52888 -52763 -52541 -47314 -46994 -46019 -44913 -39850 -38879 -38805 -38481 -38236 -37486 -35818 -33049 -32676 -32032 -29113 -24783 -22162 -21799 -18640 -18185 -16559 -14684 -14203 -10753 -10525 -9882 -3812 -2730 -2723 -2556 -2221 -2033 760 1155 1715 1996 2406 4245 5335 6602 7266 9161 11292 12117 14799 14967 14992 16023 18009 19859 21562 22077 23040 24886 28370 30956 33608 35700 36163 37320 38395 38767 40444 40779 46231 46501 46802 48155 51479 51868 52218 52562 52802 53534 53676 57399 57606 59389 59786 60818 61266 63111 64903 +0 diff --git a/Student/task3/function_test2021/067_sort_test7.sy b/Student/task3/function_test2021/067_sort_test7.sy new file mode 100644 index 0000000..50561d3 --- /dev/null +++ b/Student/task3/function_test2021/067_sort_test7.sy @@ -0,0 +1,47 @@ +int buf[2][100]; + +// sort [l, r) +void merge_sort(int l, int r) +{ + if (l + 1 >= r) + return; + + int mid = (l + r) / 2; + merge_sort(l, mid); + merge_sort(mid, r); + + int i = l, j = mid, k = l; + while (i < mid && j < r) { + if (buf[0][i] < buf[0][j]) { + buf[1][k] = buf[0][i]; + i = i + 1; + } else { + buf[1][k] = buf[0][j]; + j = j + 1; + } + k = k + 1; + } + while (i < mid) { + buf[1][k] = buf[0][i]; + i = i + 1; + k = k + 1; + } + while (j < r) { + buf[1][k] = buf[0][j]; + j = j + 1; + k = k + 1; + } + + while (l < r) { + buf[0][l] = buf[1][l]; + l = l + 1; + } +} + +int main() +{ + int n = getarray(buf[0]); + merge_sort(0, n); + putarray(n, buf[0]); + return 0; +} diff --git a/Student/task3/function_test2021/068_genealogical_tree.in b/Student/task3/function_test2021/068_genealogical_tree.in new file mode 100644 index 0000000..0a80e02 --- /dev/null +++ b/Student/task3/function_test2021/068_genealogical_tree.in @@ -0,0 +1 @@ +0 4 5 1 0 1 0 5 3 0 3 0 diff --git a/Student/task3/function_test2021/068_genealogical_tree.out b/Student/task3/function_test2021/068_genealogical_tree.out new file mode 100644 index 0000000..a09d72d --- /dev/null +++ b/Student/task3/function_test2021/068_genealogical_tree.out @@ -0,0 +1,6 @@ +2 +4 +5 +3 +1 +0 diff --git a/Student/task3/function_test2021/068_genealogical_tree.sy b/Student/task3/function_test2021/068_genealogical_tree.sy new file mode 100644 index 0000000..cdb10f9 --- /dev/null +++ b/Student/task3/function_test2021/068_genealogical_tree.sy @@ -0,0 +1,68 @@ +int map[10][10]; +int indegree[10]; +int queue[10]; +void topo(int n) +{ + int m=0; + int t=0; + int i,j; + i=1; + j=1; + while(i<=n) + { + j=1; + while(j<=n) + { + if(indegree[j]==0) + { + + m=j; + break; + } + j=j+1; + } + queue[t]=m; + t=t+1; + indegree[m]=-1; + j=1; + while(j<=n) + + { + if(map[m][j]) + { + indegree[j]=indegree[j]-1; + } + j=j+1; + } + i=i+1; + } + i=0; + while(i 0){ + rem = m % n; + m = n; + n = rem; + } + return m; +} +int main(){ + int n,m; + int num; + m=getint(); + n=getint(); + num=fun(m,n); + putint(num); + + return 0; +} diff --git a/Student/task3/function_test2021/070_multiplication_puzzle.out b/Student/task3/function_test2021/070_multiplication_puzzle.out new file mode 100644 index 0000000..c92444c --- /dev/null +++ b/Student/task3/function_test2021/070_multiplication_puzzle.out @@ -0,0 +1,2 @@ +3650 +0 diff --git a/Student/task3/function_test2021/070_multiplication_puzzle.sy b/Student/task3/function_test2021/070_multiplication_puzzle.sy new file mode 100644 index 0000000..1ac205a --- /dev/null +++ b/Student/task3/function_test2021/070_multiplication_puzzle.sy @@ -0,0 +1,32 @@ +int a[6]={10,1,50,50,20,5}; +int dp[10][10]; +int main() +{ + int n; + n=6; + + int k,i,t,j,aa; + k=3; + while(k<=n) + { + i=0; + while(i 1 && array[loc - 1] != -1) { + mmerge(loc, loc - 1); + } + if (a < n && array[loc + n] != -1) { + mmerge(loc, loc + n); + } + if (a > 1 && array[loc - n] != -1) { + mmerge(loc, loc - n); + } + + if (array[0] != -1 && array[k] != -1 && findfa(0) == findfa(k)) { + flag = 1; + int tmp = i + 1; + putint(tmp); + putch(10); + } + } + + i = i + 1; + } + if (!flag) { + putint(-1); + putch(10); + } + } + return 0; +} diff --git a/Student/task3/function_test2021/073_backpack.out b/Student/task3/function_test2021/073_backpack.out new file mode 100644 index 0000000..227eae2 --- /dev/null +++ b/Student/task3/function_test2021/073_backpack.out @@ -0,0 +1,2 @@ +15 +0 diff --git a/Student/task3/function_test2021/073_backpack.sy b/Student/task3/function_test2021/073_backpack.sy new file mode 100644 index 0000000..c54d6ff --- /dev/null +++ b/Student/task3/function_test2021/073_backpack.sy @@ -0,0 +1,63 @@ +int V[200][200]={}; +int KnapSack(int n, int w[], int v[], int x[], int C) +{ + int i, j; + i=1; + while(i<=n) + { + j=0; + while(jtmp2) + { + V[i][j] = tmp1; + } + else + { + V[i][j] = tmp2; + } + + } + j=j+1; + } + i=i+1; + } + + j = C; + i=n; + while(i>=1) + { + if (V[i][j]>V[i - 1][j]) + { + x[i] = 1; + j = j - w[i]; + } + else + { + + x[i] = 0; + } + i=i-1; + } + return V[n][C]; +} + +int main() +{ + int s; + int w[6] = {0,2,2,6,5,4}; + int v[6] = {0,6,3,5,4,6}; + int x[6]; + int n = 5; + int C=10; + s = KnapSack(n, w, v, x, C); + putint(s); + return 0; + +} diff --git a/Student/task3/function_test2021/074_matrix_add.out b/Student/task3/function_test2021/074_matrix_add.out new file mode 100644 index 0000000..28b5f4b --- /dev/null +++ b/Student/task3/function_test2021/074_matrix_add.out @@ -0,0 +1,4 @@ +024 +024 +024 +0 diff --git a/Student/task3/function_test2021/074_matrix_add.sy b/Student/task3/function_test2021/074_matrix_add.sy new file mode 100644 index 0000000..4f9158e --- /dev/null +++ b/Student/task3/function_test2021/074_matrix_add.sy @@ -0,0 +1,70 @@ +int M; +int L; +int N; + + +int add(int a0[],int a1[], int a2[],int b0[],int b1[],int b2[],int c0[],int c1[],int c2[]) +{ + int i; + i=0; + while(i -1) { + t = c2[i]; + j = len1 - 1; + while (j > -1) { + temp = result[n] + t * c1[j]; + if(temp >= 10) { + result[n] = (temp); + result[n-1] = result[n-1] + temp / 10; + } + else + result[n] = temp; + j = j - 1; + n = n - 1; + } + n = n + len1 - 1; + i = i - 1; + } + + if(result[0] != 0) + putint(result[0]); + + i = 1; + while (i <= len1 + len2 - 1) { + putint(result[i]); + i = i + 1; + } + + return 0; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/079_calculator.in b/Student/task3/function_test2021/079_calculator.in new file mode 100644 index 0000000..d488a8b --- /dev/null +++ b/Student/task3/function_test2021/079_calculator.in @@ -0,0 +1 @@ +(4 - (3 - 5) * 2 + 100) % (2^3 - 1) / 2 + 1 diff --git a/Student/task3/function_test2021/079_calculator.out b/Student/task3/function_test2021/079_calculator.out new file mode 100644 index 0000000..389e262 --- /dev/null +++ b/Student/task3/function_test2021/079_calculator.out @@ -0,0 +1,2 @@ +2 +0 diff --git a/Student/task3/function_test2021/079_calculator.sy b/Student/task3/function_test2021/079_calculator.sy new file mode 100644 index 0000000..f67a932 --- /dev/null +++ b/Student/task3/function_test2021/079_calculator.sy @@ -0,0 +1,184 @@ +int ints[10000]; +int intt; +int chas[10000]; +int chat; +int i=0, ii=1; +int c; +int get[10000]; +int get2[10000]; + +int isdigit(int x) { + if (x >= 48 && x <= 57) + return 1; + return 0; +} + +int power(int b, int a) { + int result = 1; + while (a != 0) { + result = result * b; + a = a - 1; + } + return result; +} + +int getstr(int get[]) { + int x = getch(); + int length = 0; + while (x != 13 && x != 10) { + get[length] = x; + length = length + 1; + x = getch(); + } + return length; +} + +void intpush(int x) +{ + intt = intt + 1; + ints[intt] = x; +} +void chapush(int x) +{ + chat = chat + 1; + chas[chat] = x; +} +int intpop() +{ + intt = intt - 1; + return ints[intt + 1]; +} +int chapop() +{ + chat = chat - 1; + return chas[chat + 1]; +} +void intadd(int x) +{ + ints[intt] = ints[intt] * 10; + ints[intt] = ints[intt] + x; +} + +int find() +{ + c = chapop(); + get2[ii] = 32; + get2[ii + 1] = c; + ii = ii + 2; + if (chat == 0) return 0; + return 1; +} + +int main() +{ + intt=0; + chat=0; + int lengets = getstr(get); + while (i < lengets) + { + if (isdigit(get[i]) == 1) + { + get2[ii] = get[i]; + ii = ii + 1; + } + else + { + if(get[i] == 40) chapush(40); + if(get[i] == 94) chapush(94); + if(get[i] == 41) + { + c = chapop(); + while (c != 40) + { + get2[ii] = 32; + get2[ii + 1]=c; + ii = ii + 2; + c = chapop(); + } + } + if (get[i] == 43) + { + while (chas[chat] == 43 || chas[chat] == 45 || chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94) + { + if (find()==0)break; + } + chapush(43); + } + if (get[i] == 45) + { + while (chas[chat] == 43 || chas[chat] == 45 ||chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94) + { + if(find()==0)break; + } + chapush(45); + } + if(get[i] == 42) + { + while (chas[chat] == 42 || chas[chat] == 47 ||chas[chat] == 37 || chas[chat] == 94) + { + if (find()==0)break; + } + chapush(42); + } + if (get[i] == 47) + { + while (chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94) + { + if (find()==0)break; + } + chapush(47); + } + if (get[i] == 37) + { + while (chas[chat] == 42 || chas[chat] == 47 || chas[chat] == 37 || chas[chat] == 94) + { + if (find()==0)break; + } + chapush(37); + } + get2[ii] = 32; + ii = ii + 1; + } + i = i + 1; + } + while(chat > 0) + { + int c = chapop(); + get2[ii] = 32; + get2[ii + 1]=c; + ii = ii + 2; + } + get2[ii]= 64; + i = 1; + while (get2[i] != 64) + { + if (get2[i] == 43 || get2[i] == 45 || get2[i] == 42 || get2[i] == 47 || get2[i] == 37 || get2[i] == 94) + { + int a=intpop();int b=intpop();int c; + if (get2[i] == 43) c = a + b; + if (get2[i] == 45) c = b - a; + if (get2[i] == 42) c = a * b; + if (get2[i] == 47) c = b / a; + if (get2[i] == 37) c = b % a; + if (get2[i] == 94) c = power(b,a); + intpush(c); + } + else + { + if(get2[i] != 32) + { + intpush(get2[i] - 48); + ii=1; + while(get2[i+ii] != 32) + { + intadd(get2[i+ii] - 48); + ii = ii + 1; + } + i = i + ii-1; + } + } + i = i + 1; + } + putint(ints[1]); + return 0; +} diff --git a/Student/task3/function_test2021/080_color.in b/Student/task3/function_test2021/080_color.in new file mode 100644 index 0000000..36826c2 --- /dev/null +++ b/Student/task3/function_test2021/080_color.in @@ -0,0 +1,2 @@ +5 +2 2 2 2 2 \ No newline at end of file diff --git a/Student/task3/function_test2021/080_color.out b/Student/task3/function_test2021/080_color.out new file mode 100644 index 0000000..14f95f6 --- /dev/null +++ b/Student/task3/function_test2021/080_color.out @@ -0,0 +1,2 @@ +39480 +56 diff --git a/Student/task3/function_test2021/080_color.sy b/Student/task3/function_test2021/080_color.sy new file mode 100644 index 0000000..a18319e --- /dev/null +++ b/Student/task3/function_test2021/080_color.sy @@ -0,0 +1,69 @@ +const int maxn = 18; +const int mod = 1000000007; +int dp[maxn][maxn][maxn][maxn][maxn][7]; +int list[200]; + +int equal(int a, int b) { + if (a == b) + return 1; + return 0; +} + +int dfs(int a, int b, int c, int d, int e, int last){ + if(dp[a][b][c][d][e][last] != -1) + return dp[a][b][c][d][e][last]; + if(a + b + c + d + e == 0) + return 1; + int ans = 0; + if (a) ans = (ans + (a - equal(last, 2)) * dfs(a - 1, b, c, d, e, 1)) % mod; + if (b) ans = (ans + (b - equal(last, 3)) * dfs(a + 1, b - 1, c, d, e, 2)) % mod; + if (c) ans = (ans + (c - equal(last, 4)) * dfs(a, b + 1, c - 1, d, e, 3)) % mod; + if (d) ans = (ans + (d - equal(last, 5)) * dfs(a, b, c + 1, d - 1, e, 4)) % mod; + if (e) ans = (ans + e * dfs(a, b, c, d + 1, e - 1, 5)) % mod; + dp[a][b][c][d][e][last] = ans % mod; + return dp[a][b][c][d][e][last]; +} + +int cns[20]; + +int main(){ + int n = getint(); + int i = 0; + while (i < maxn) { + int j = 0; + while(j < maxn) { + int k = 0; + while(k < maxn) { + int l = 0; + while (l < maxn) { + int m = 0; + while (m < maxn) { + int h = 0; + while (h < 7) { + dp[i][j][k][l][m][h] = -1; + h = h + 1; + } + m = m + 1; + } + l = l + 1; + } + k = k + 1; + } + j = j + 1; + } + i = i + 1; + } + + i = 0; + while (i < n) { + list[i] = getint(); + cns[list[i]] = cns[list[i]] + 1; + i = i + 1; + } + + int ans = dfs(cns[1], cns[2], cns[3], cns[4], cns[5], 0); + + putint(ans); + + return ans; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/100_array_concat.out b/Student/task3/function_test2021/100_array_concat.out new file mode 100644 index 0000000..64d98dc --- /dev/null +++ b/Student/task3/function_test2021/100_array_concat.out @@ -0,0 +1,2 @@ +012012 +0 diff --git a/Student/task3/function_test2021/100_array_concat.sy b/Student/task3/function_test2021/100_array_concat.sy new file mode 100644 index 0000000..7e69e38 --- /dev/null +++ b/Student/task3/function_test2021/100_array_concat.sy @@ -0,0 +1,52 @@ + +int concat(int a0[],int b0[],int c0[]) +{ + int i; + i=0; + while(i<3) + { + c0[i]=a0[i]; + + i=i+1; + } + int j; + j=0; + while(j<3) + { + c0[i]=b0[j]; + i=i+1; + j=j+1; + } + + return 0; + +} + +int main() +{ + int a0[3];int a1[3]; int a2[3];int b0[3];int b1[3];int b2[3];int c0[6];int c1[3];int c2[3]; + int i; + i=0; + while(i<3) + { + a0[i]=i; + a1[i]=i; + a2[i]=i; + b0[i]=i; + b1[i]=i; + b2[i]=i; + i=i+1; + } + i=concat( a0,b0, c0); + int x; + while(i<6) + { + x = c0[i]; + putint(x); + i=i+1; + } + x = 10; + putch(x); + + return 0; +} diff --git a/Student/task3/function_test2021/101_insert_order.in b/Student/task3/function_test2021/101_insert_order.in new file mode 100644 index 0000000..c5b431b --- /dev/null +++ b/Student/task3/function_test2021/101_insert_order.in @@ -0,0 +1 @@ +50 \ No newline at end of file diff --git a/Student/task3/function_test2021/101_insert_order.out b/Student/task3/function_test2021/101_insert_order.out new file mode 100644 index 0000000..0da658a --- /dev/null +++ b/Student/task3/function_test2021/101_insert_order.out @@ -0,0 +1,11 @@ +1 +3 +4 +7 +8 +11 +13 +18 +50 +50 +0 diff --git a/Student/task3/function_test2021/101_insert_order.sy b/Student/task3/function_test2021/101_insert_order.sy new file mode 100644 index 0000000..9d1e7b8 --- /dev/null +++ b/Student/task3/function_test2021/101_insert_order.sy @@ -0,0 +1,55 @@ +//int n; +int N; +int insert(int a[],int x) +{ + int p; + int i; + p=0; + + while(x>a[p]&&pp) + { + a[i]=a[i-1]; + a[p]=x; + i=i-1; + + } + + return 0; +} + +int main() +{ + N=10; + int a[11]; + //a[0]=1; + a[0]=1; + a[1]=3; + a[2]=4; + a[3]=7; + a[4]=8; + a[5]=11; + a[6]=13; + a[7]=18; + a[8]=56; + a[9]=78; + int x; + int i; + i=0; + x=getint(); + x=insert(a,x); + //while() + while(i -1 && s[c] == 0){ + c = c - 1; + } + if(c == -1) + return 0; + int i; + i = c; + while(i > -1){ + if(s[i] == 0) + return n - i - 1 - (n - 1 - c); + i = i - 1; + } + return c - i; +} +int main(){ + int res; + int a[10]; + a[0]=-4;a[1]=3;a[2]=9;a[3]=-2;a[4]=0; + a[5]=1;a[6]=-6;a[7]=5;a[8]=7;a[9]=8; + res = 10; + res = lengthOfLastWord(a, res); + return res; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/85_multi.out b/Student/task3/function_test2021/85_multi.out new file mode 100644 index 0000000..9aea9e0 --- /dev/null +++ b/Student/task3/function_test2021/85_multi.out @@ -0,0 +1,2 @@ +0 +0 \ No newline at end of file diff --git a/Student/task3/function_test2021/85_multi.sy b/Student/task3/function_test2021/85_multi.sy new file mode 100644 index 0000000..a73ac10 --- /dev/null +++ b/Student/task3/function_test2021/85_multi.sy @@ -0,0 +1,19 @@ +int main() +{ + //newline=10; + int i; + int sum; + sum=0; + //m = 1478; + //int t; + i=0; + while(i<21) + { + sum=sum*i; + i=i+1; + } + + putint(sum); + + return 0; +} diff --git a/Student/task3/function_test2021/86_max_subsequence_sum.out b/Student/task3/function_test2021/86_max_subsequence_sum.out new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/Student/task3/function_test2021/86_max_subsequence_sum.out @@ -0,0 +1 @@ +25 diff --git a/Student/task3/function_test2021/86_max_subsequence_sum.sy b/Student/task3/function_test2021/86_max_subsequence_sum.sy new file mode 100644 index 0000000..bbb4a84 --- /dev/null +++ b/Student/task3/function_test2021/86_max_subsequence_sum.sy @@ -0,0 +1,30 @@ +int maxSubArray(int nums[], int n) { + if(n == 0) + return 0; + if(n == 1) + return nums[0]; + int sum; + sum = nums[0]; + int max; + max = sum; + int i; + i = 1; + while(i < n){ + if(sum < 0) + sum = 0; + sum = sum + nums[i]; + if(max < sum) + max = sum; + i = i + 1; + } + return max; +} +int main(){ + int res; + int a[10]; + a[0]=-4;a[1]=3;a[2]=9;a[3]=-2;a[4]=0; + a[5]=1;a[6]=-6;a[7]=5;a[8]=7;a[9]=8; + res = 10; + res = maxSubArray(a, res); + return res; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/87_enum.out b/Student/task3/function_test2021/87_enum.out new file mode 100644 index 0000000..f7ac686 --- /dev/null +++ b/Student/task3/function_test2021/87_enum.out @@ -0,0 +1,2 @@ +01000 +0 diff --git a/Student/task3/function_test2021/87_enum.sy b/Student/task3/function_test2021/87_enum.sy new file mode 100644 index 0000000..fc98413 --- /dev/null +++ b/Student/task3/function_test2021/87_enum.sy @@ -0,0 +1,27 @@ +int main() +{ + int i; + int j; + int k; + int t; + i=0;j=0;k=0; + while(i<21) + { + while(j<101-i) + { + k=100-i-j; + if(5*i+1*j+k/2==100) + { + putint(i); + putint(j); + putint(k); + t=10; + putch(t); + } + j=j+1; + } + i=i+1; + } + + return 0; +} diff --git a/Student/task3/function_test2021/88_exchange_value.in b/Student/task3/function_test2021/88_exchange_value.in new file mode 100644 index 0000000..4271cf2 --- /dev/null +++ b/Student/task3/function_test2021/88_exchange_value.in @@ -0,0 +1,2 @@ +4 +20 \ No newline at end of file diff --git a/Student/task3/function_test2021/88_exchange_value.out b/Student/task3/function_test2021/88_exchange_value.out new file mode 100644 index 0000000..f76b2c0 --- /dev/null +++ b/Student/task3/function_test2021/88_exchange_value.out @@ -0,0 +1,3 @@ +20 +4 +0 diff --git a/Student/task3/function_test2021/88_exchange_value.sy b/Student/task3/function_test2021/88_exchange_value.sy new file mode 100644 index 0000000..24f3536 --- /dev/null +++ b/Student/task3/function_test2021/88_exchange_value.sy @@ -0,0 +1,25 @@ +int n; + +int main() +{ + //newline=10; + int i; + int j; + //m = 1478; + //int t; + i=getint(); + j=getint(); + int temp; + temp=i; + i=j; + j=temp; + + putint(i); + temp = 10; + putch(temp); + putint(j); + temp = 10; + putch(temp); + + return 0; +} diff --git a/Student/task3/function_test2021/89_itera_sqrt.out b/Student/task3/function_test2021/89_itera_sqrt.out new file mode 100644 index 0000000..3ec8ae5 --- /dev/null +++ b/Student/task3/function_test2021/89_itera_sqrt.out @@ -0,0 +1,2 @@ +20 +0 diff --git a/Student/task3/function_test2021/89_itera_sqrt.sy b/Student/task3/function_test2021/89_itera_sqrt.sy new file mode 100644 index 0000000..1b970d1 --- /dev/null +++ b/Student/task3/function_test2021/89_itera_sqrt.sy @@ -0,0 +1,27 @@ +int fsqrt(int a) +{ + int x0=0; + int x1; + x1=a/2; + while(x0-x1!=0) + { + x0=x1; + x1=(x0+a/x0); + x1=x1/2; + } + + return x1; + +} + +int main() +{ + int a; + a=400; + int res; + res=fsqrt(a); + putint(res); + res = 10; + putch(res); + return 0; +} diff --git a/Student/task3/function_test2021/90_max_container.out b/Student/task3/function_test2021/90_max_container.out new file mode 100644 index 0000000..f6b91e0 --- /dev/null +++ b/Student/task3/function_test2021/90_max_container.out @@ -0,0 +1 @@ +56 diff --git a/Student/task3/function_test2021/90_max_container.sy b/Student/task3/function_test2021/90_max_container.sy new file mode 100644 index 0000000..df966d4 --- /dev/null +++ b/Student/task3/function_test2021/90_max_container.sy @@ -0,0 +1,33 @@ +int maxArea(int height[], int n) { + int i; + int j; + i = 0; + j = n - 1; + int max_val; + max_val = -1; + while(i < j){ + int area; + if(height[i] < height[j]) + area = (j - i) * height[i]; + else + area = (j - i) * height[j]; + if(area > max_val){ + max_val = area; + } + if(height[i] > height[j]) + j = j - 1; + else + i = i + 1; + } + return max_val; +} + +int main(){ + int res; + int a[10]; + a[0]=3;a[1]=3;a[2]=9;a[3]=0;a[4]=0; + a[5]=1;a[6]=1;a[7]=5;a[8]=7;a[9]=8; + res = 10; + res = maxArea(a, res); + return res; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/91_int_factor_sum.out b/Student/task3/function_test2021/91_int_factor_sum.out new file mode 100644 index 0000000..730a054 --- /dev/null +++ b/Student/task3/function_test2021/91_int_factor_sum.out @@ -0,0 +1 @@ +172 diff --git a/Student/task3/function_test2021/91_int_factor_sum.sy b/Student/task3/function_test2021/91_int_factor_sum.sy new file mode 100644 index 0000000..2344c11 --- /dev/null +++ b/Student/task3/function_test2021/91_int_factor_sum.sy @@ -0,0 +1,33 @@ +int N; + +int newline; + +int factor(int n ) +{ + int i; + int sum; + sum=0; + i=1; + while(i -1){ + j=n-2; + while(j > -1){ + dp[i*3+j] = dp[(i+1)*3+j] + dp[i*3+j+1]; + j = j - 1; + } + i = i - 1; + } + return dp[0]; +} +int main(){ + int res; + int n; + n=3; + res = uniquePaths(n, n); + return res; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/93_decbinoct.out b/Student/task3/function_test2021/93_decbinoct.out new file mode 100644 index 0000000..e4848b1 --- /dev/null +++ b/Student/task3/function_test2021/93_decbinoct.out @@ -0,0 +1,2 @@ +110010000 +0 diff --git a/Student/task3/function_test2021/93_decbinoct.sy b/Student/task3/function_test2021/93_decbinoct.sy new file mode 100644 index 0000000..8cc78ba --- /dev/null +++ b/Student/task3/function_test2021/93_decbinoct.sy @@ -0,0 +1,31 @@ +int dec2bin(int a) +{ + int res; + int k; + int i; + int temp; + res=0; + k=1; + temp=a; + while(temp!=0) + { + i=temp%2; + res=k*i+res; + k=k*10; + temp=temp/2; + } + return res; + +} + +int main() +{ + int a; + a=400; + int res; + res=dec2bin(a); + putint(res); + res = 10; + putch(res); + return 0; +} diff --git a/Student/task3/function_test2021/94_lcm.in b/Student/task3/function_test2021/94_lcm.in new file mode 100644 index 0000000..4271cf2 --- /dev/null +++ b/Student/task3/function_test2021/94_lcm.in @@ -0,0 +1,2 @@ +4 +20 \ No newline at end of file diff --git a/Student/task3/function_test2021/94_lcm.out b/Student/task3/function_test2021/94_lcm.out new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/Student/task3/function_test2021/94_lcm.out @@ -0,0 +1 @@ +20 diff --git a/Student/task3/function_test2021/94_lcm.sy b/Student/task3/function_test2021/94_lcm.sy new file mode 100644 index 0000000..4930995 --- /dev/null +++ b/Student/task3/function_test2021/94_lcm.sy @@ -0,0 +1,35 @@ +int n; + +int gcd(int m,int n) +{ + int a; + int b; + a=m; + b=n; + + int t; + int r; + + if(m n - 2) + return 1; + int dp[10]; + int i; + i = 0; + while(i -1){ + int j; + if(nums[i] < n - 1 - i){ + j = nums[i]; + } + else + j = n - 1 - i; + while(j > -1){ + if(dp[i+j] != 0){ + dp[i] = 1; + } + j = j - 1; + } + i = i - 1; + } + + return dp[0]; +} +int main(){ + int res; + int a[10]; + a[0]=3;a[1]=3;a[2]=9;a[3]=0;a[4]=0; + a[5]=1;a[6]=1;a[7]=5;a[8]=7;a[9]=8; + res = 10; + res = canJump(a, res); + return res; +} \ No newline at end of file diff --git a/Student/task3/function_test2021/96_int_split.out b/Student/task3/function_test2021/96_int_split.out new file mode 100644 index 0000000..d3c7935 --- /dev/null +++ b/Student/task3/function_test2021/96_int_split.out @@ -0,0 +1,5 @@ +1 +4 +7 +8 +0 \ No newline at end of file diff --git a/Student/task3/function_test2021/96_int_split.sy b/Student/task3/function_test2021/96_int_split.sy new file mode 100644 index 0000000..fb1e91e --- /dev/null +++ b/Student/task3/function_test2021/96_int_split.sy @@ -0,0 +1,40 @@ +int N; + +int newline; + +int split(int n ,int a[]) +{ + int i; + i=N-1; + while(i!=-1) + { + a[i]=n%10; + n=n/10; + i=i-1; + + } + + return 0; +} + +int main() +{ + N=4; + newline=10; + int i; + int m; + int b[4]; + m = 1478; + m = split(m,b); + int t; + i=0; + while(i<4) + { + t=b[i]; + putint(t); + putch(newline); + i=i+1; + + } + return 0; +} diff --git a/Student/task3/function_test2021/97_enc_dec.out b/Student/task3/function_test2021/97_enc_dec.out new file mode 100644 index 0000000..fda270a --- /dev/null +++ b/Student/task3/function_test2021/97_enc_dec.out @@ -0,0 +1,2 @@ +401 +0 diff --git a/Student/task3/function_test2021/97_enc_dec.sy b/Student/task3/function_test2021/97_enc_dec.sy new file mode 100644 index 0000000..5df25f9 --- /dev/null +++ b/Student/task3/function_test2021/97_enc_dec.sy @@ -0,0 +1,38 @@ +int enc(int a) +{ + if(a>25) + a=a+60; + else + { + a=a-15; + } + + return a; + +} + +int dec(int a) +{ + if (a>85) + a=a-59; + else + { + a=a+14; + } + + return a; + +} + +int main() +{ + int a; + a=400; + int res; + res=enc(a); + res=dec(res); + putint(res); + res = 10; + putch(res); + return 0; +} diff --git a/Student/task3/function_test2021/98_palindrome_number.out b/Student/task3/function_test2021/98_palindrome_number.out new file mode 100644 index 0000000..a79e55f --- /dev/null +++ b/Student/task3/function_test2021/98_palindrome_number.out @@ -0,0 +1,2 @@ +1221 +0 diff --git a/Student/task3/function_test2021/98_palindrome_number.sy b/Student/task3/function_test2021/98_palindrome_number.sy new file mode 100644 index 0000000..19aa459 --- /dev/null +++ b/Student/task3/function_test2021/98_palindrome_number.sy @@ -0,0 +1,42 @@ +int palindrome(int n) +{ + int a[4]; + int j; + int flag; + j=0; + while(j<4) + { + a[j]=n%10; + n=n/10; + j=j+1; + } + + if(a[0]==a[3] && a[1]==a[2]) + { + flag=1; + }else{ + flag=0; + } + return flag; +} + +int main() +{ + int test; + test=1221; + int flag; + flag=palindrome(test); + if(flag==1) + putint(test); + else + { + flag = 0; + putint(flag); + } + + flag = 10; + putch(flag); + + return 0; + +} diff --git a/Student/task3/function_test2021/99_bin_search.in b/Student/task3/function_test2021/99_bin_search.in new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/Student/task3/function_test2021/99_bin_search.in @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/Student/task3/function_test2021/99_bin_search.out b/Student/task3/function_test2021/99_bin_search.out new file mode 100644 index 0000000..cdfade7 --- /dev/null +++ b/Student/task3/function_test2021/99_bin_search.out @@ -0,0 +1,2 @@ +6 +0 diff --git a/Student/task3/function_test2021/99_bin_search.sy b/Student/task3/function_test2021/99_bin_search.sy new file mode 100644 index 0000000..ce86475 --- /dev/null +++ b/Student/task3/function_test2021/99_bin_search.sy @@ -0,0 +1,51 @@ + +int main() +{ + //newline=10; + int i; + int sum; + int a[10]; + sum=0; + //m = 1478; + //int t; + i=0; + while(i<10) + { + a[i]=i+1; + i=i+1; + } + int x; + int high; + int low; + int mid; + int n; + n=10; + x=getint(); + high=n-1; + low=0; + mid=(high+low)/2; + while(a[mid]!=x && low < high) + { + mid=(high+low)/2; + if(x