From cab51e585b957afcb91ce168f4ebda70e47f6439 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 11 Nov 2019 14:12:36 +0300 Subject: [PATCH 01/14] Update t01_max.cpp --- src/main/cpp/t01_max.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/cpp/t01_max.cpp b/src/main/cpp/t01_max.cpp index 3bf79a94e..73e4282b2 100644 --- a/src/main/cpp/t01_max.cpp +++ b/src/main/cpp/t01_max.cpp @@ -27,6 +27,25 @@ using namespace std; int t01_max() { + int n, m, num, col, row; + cin >> n>> m; + int arr[n][m]; + for (int i = 0; i < n; i++){ + for (int j = 0; j < m; j++){ + cin >> arr[i][j]; + } + } + num = arr[0][0]; + for (int i = 0; i < n; i++){ + for (int j = 0; j < m; j++){ + if (arr[i][j] > num){ + num = arr[i][j]; + col = i; + row = j; + } + } + } + cout << col << " " << row; return 0; } From 143307c44c550777be32be9cffa8c01c84b54d55 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 11 Nov 2019 20:00:22 +0300 Subject: [PATCH 02/14] Update t02_star.cpp --- src/main/cpp/t02_star.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/cpp/t02_star.cpp b/src/main/cpp/t02_star.cpp index 763f8a249..10bbe1bbe 100644 --- a/src/main/cpp/t02_star.cpp +++ b/src/main/cpp/t02_star.cpp @@ -24,6 +24,34 @@ using namespace std; int t02_star() { + int n; + cin >> n; + char arr[n][n]; + for (int i = 0; i < n; i++){ + for (int j = 0; j < n; j++){ + arr[i][j] = '.'; + } + } + for (int i = 0; i < n;i++){ + for (int j = 0; j < n; j++){ + if (i == n/2 || j == n/2){ + arr[i][j] = '*'; + } + } + } + + for (int i = 0, j = 0; i < n && j < n; i++, j++){ + arr[i][j] = '*'; + } + for (int i = n-1, j = 0; i > -1 && j < n; --i, j++){ + arr[i][j] = '*'; + } + for (int i = 0; i < n; i++){ + for (int j = 0; j < n; j++){ + cout << arr[i][j] << ' '; + } + cout << endl; + } return 0; } From 83df804a0d66ba66d00ff6e07a9b575820201420 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 2 Dec 2019 18:51:18 +0300 Subject: [PATCH 03/14] Update t03_diag.cpp --- src/main/cpp/t03_diag.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t03_diag.cpp b/src/main/cpp/t03_diag.cpp index e5234075b..56b2af37b 100644 --- a/src/main/cpp/t03_diag.cpp +++ b/src/main/cpp/t03_diag.cpp @@ -22,6 +22,25 @@ using namespace std; int t03_diag() { - + int n= 0, i =0; + cin >> n; + int arr[n][n]; + for ( i = 0; i < n; i++){ + for (int row=i, col=0;row Date: Mon, 2 Dec 2019 18:53:54 +0300 Subject: [PATCH 04/14] Update t03_diag.cpp --- src/main/cpp/t03_diag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cpp/t03_diag.cpp b/src/main/cpp/t03_diag.cpp index 56b2af37b..64023c72c 100644 --- a/src/main/cpp/t03_diag.cpp +++ b/src/main/cpp/t03_diag.cpp @@ -41,6 +41,6 @@ int t03_diag() { } cout << endl; } -} + return 0; } From 6b5e5a8812b207bc02f9456d4eca22bf9a6f1d7d Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 2 Dec 2019 19:11:30 +0300 Subject: [PATCH 05/14] Update t04_swap.cpp --- src/main/cpp/t04_swap.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t04_swap.cpp b/src/main/cpp/t04_swap.cpp index 3ac81b477..58a355e82 100644 --- a/src/main/cpp/t04_swap.cpp +++ b/src/main/cpp/t04_swap.cpp @@ -25,6 +25,29 @@ using namespace std; int t04_swap() { - + int n, m, i, j; + cin >> n >> m; + int arr[n][m]; + for (int a = 0; a < n; a++){ + for (int b = 0; b < m; b++){ + cin >> arr[a][b]; + } + } + i = 0, j =0; + cin >> i >> j; + for (int h =0; h < n; h++){ + int c = arr[h][i]; + int b = arr[h][j]; + int d = c; + arr[h][i]= b; + arr[h][j]= d; + } + + for (int a = 0; a < n; a++){ + for (int b = 0; b Date: Mon, 9 Dec 2019 04:41:25 +0300 Subject: [PATCH 06/14] Update t05_kdiag.cpp --- src/main/cpp/t05_kdiag.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t05_kdiag.cpp b/src/main/cpp/t05_kdiag.cpp index 92ee365c2..32c3c4144 100644 --- a/src/main/cpp/t05_kdiag.cpp +++ b/src/main/cpp/t05_kdiag.cpp @@ -38,6 +38,23 @@ using namespace std; int t05_kdiag() { - + int n, num; + cin >> n; + int arr[n][n]; + + for (int i = 0; i < n; i++){ + for (int j = 0; j < n; j++){ + cin >> arr[i][j]; + } + } + + cin >> num; + for (int i = 0; i < n; i++){ + for (int j = 0; j < n; j++){ + if (j == i - num){ + cout << arr[i][j] << " "; + } + } + } return 0; } From 7b20144e8ef327d8c21d4326079c52bf0e91f693 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 9 Dec 2019 04:55:03 +0300 Subject: [PATCH 07/14] Update t06_cinema.cpp --- src/main/cpp/t06_cinema.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t06_cinema.cpp b/src/main/cpp/t06_cinema.cpp index beaf78dae..4a4e58903 100644 --- a/src/main/cpp/t06_cinema.cpp +++ b/src/main/cpp/t06_cinema.cpp @@ -29,6 +29,31 @@ using namespace std; int t06_cinema() { - + int n, num, m, cou, row; + cin >> n >> m; + int arr[n][m]; + + for (int i = 0; i < n; i++){ + for (int j = 0; j < m; j++){ + cin >> arr[i][j]; + } + } + + cin >> num; + for (int i = 0; i < n; i++){ + for (int j = 1; j < m; j++){ + if (arr[i][j] == 0){ + cou++; + if (cou == num){ + row = 1 + i; + break; + } + } + else { + cou = 0; + } + } + } + cout << row; return 0; } From 4f7e18ea7762e9237a07e88c71b88b7345a1cd1e Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 9 Dec 2019 14:39:31 +0300 Subject: [PATCH 08/14] Update t07_snake.cpp --- src/main/cpp/t07_snake.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t07_snake.cpp b/src/main/cpp/t07_snake.cpp index 805ff1306..d0a9ac83b 100644 --- a/src/main/cpp/t07_snake.cpp +++ b/src/main/cpp/t07_snake.cpp @@ -22,6 +22,30 @@ using namespace std; int t07_snake() { - + int n, m, num; + cin >> n >> m; + int arr[n][m]; + num = 1; + for (int i = 0; i < n; i++) { + if (i % 2 == 0) { + for (int j = 0; j < m; j++){ + arr[i][j] = num; + num++; + } + } + else if ( i % 2 != 0){ + for (int j = m-1; j > -1; j--) { + arr[i][j] = num; + num++; + } + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + cout.width(4); + cout << arr[i][j] << " "; + } + cout << endl; + } return 0; } From 3be84ed16d8bf68685ab14b0a28b9abf7ea8d4e9 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Mon, 9 Dec 2019 14:46:32 +0300 Subject: [PATCH 09/14] Update t08_chess.cpp --- src/main/cpp/t08_chess.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/t08_chess.cpp b/src/main/cpp/t08_chess.cpp index 75802c2a8..03919c345 100644 --- a/src/main/cpp/t08_chess.cpp +++ b/src/main/cpp/t08_chess.cpp @@ -24,6 +24,36 @@ using namespace std; int t08_chess() { - + int n, m, num; + cin >> n >> m; + int arr[n][m]; + num = 1; + for (int i = 0; i < n; i++) { + if (i % 2 == 0) { + for (int j = 0; j < m; j+=2){ + arr[i][j] = num; + num++; + } + for (int j = 1; j < m; j+=2){ + arr[i][j] = 0; + } + } + else if ( i % 2 != 0){ + for (int j = 1; j < m; j+=2) { + arr[i][j] = num; + num++; + for (int j = 0; j < m; j+=2){ + arr[i][j] = 0; + } + } + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + cout.width(4); + cout << arr[i][j] << " "; + } + cout << endl; + } return 0; } From 1153b1b8801f0fe450feb8d77f3e5c3dbecd854b Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Wed, 25 Dec 2019 13:18:24 +0300 Subject: [PATCH 10/14] Update t09_spiral.cpp --- src/main/cpp/t09_spiral.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/t09_spiral.cpp b/src/main/cpp/t09_spiral.cpp index e6b33f466..9b86498da 100644 --- a/src/main/cpp/t09_spiral.cpp +++ b/src/main/cpp/t09_spiral.cpp @@ -17,11 +17,32 @@ #include "t09_spiral.h" #include - +#include using namespace std; int t09_spiral() { - + int num1, num2, arr[100][100] = {}, z = 0, i = 1, j = 0; + cin >> num1 >> num2; + while (z < num1 * num2) { + while (arr[i][j + 1] == 0 && j < num2){ + arr[i][++j] = ++z; + } + while (arr[i + 1][j] == 0 && i < num1){ + arr[++i][j] = ++z; + } + while (arr[i][j - 1] == 0 && j > 1){ + arr[i][--j] = ++z; + } + while (arr[i - 1][j] == 0 && i > 1){ + arr[--i][j] = ++z; + } + } + for (i = 1; i <= num1; i++) { + for (int j = 1; j <= num2; j++){ + cout << setw(4) << arr[i][j]; + } + cout << endl; + } return 0; } From f0ecb500e4181209d86d60ffff8f7496ec13b70d Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Wed, 25 Dec 2019 13:30:53 +0300 Subject: [PATCH 11/14] Update t07_snake.cpp --- src/main/cpp/t07_snake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cpp/t07_snake.cpp b/src/main/cpp/t07_snake.cpp index d0a9ac83b..57973818a 100644 --- a/src/main/cpp/t07_snake.cpp +++ b/src/main/cpp/t07_snake.cpp @@ -33,7 +33,7 @@ int t07_snake() { num++; } } - else if ( i % 2 != 0){ + else{ for (int j = m-1; j > -1; j--) { arr[i][j] = num; num++; From 938a21b9acb5e211ce21ea52ca7f80c23a60ae16 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Wed, 25 Dec 2019 13:31:16 +0300 Subject: [PATCH 12/14] Update t08_chess.cpp --- src/main/cpp/t08_chess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cpp/t08_chess.cpp b/src/main/cpp/t08_chess.cpp index 03919c345..6f77ead35 100644 --- a/src/main/cpp/t08_chess.cpp +++ b/src/main/cpp/t08_chess.cpp @@ -38,7 +38,7 @@ int t08_chess() { arr[i][j] = 0; } } - else if ( i % 2 != 0){ + else( i % 2 != 0){ for (int j = 1; j < m; j+=2) { arr[i][j] = num; num++; From 9abf1bffb45974c798dd9c6fefded29e457d78be Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Wed, 25 Dec 2019 13:33:48 +0300 Subject: [PATCH 13/14] Update t08_chess.cpp --- src/main/cpp/t08_chess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cpp/t08_chess.cpp b/src/main/cpp/t08_chess.cpp index 6f77ead35..5ca6907c1 100644 --- a/src/main/cpp/t08_chess.cpp +++ b/src/main/cpp/t08_chess.cpp @@ -38,7 +38,7 @@ int t08_chess() { arr[i][j] = 0; } } - else( i % 2 != 0){ + else{ for (int j = 1; j < m; j+=2) { arr[i][j] = num; num++; From 9a24662803804c5cd9fd96d5bbfcaccb44225ec1 Mon Sep 17 00:00:00 2001 From: chromyy <55399522+chromyy@users.noreply.github.com> Date: Wed, 25 Dec 2019 14:08:18 +0300 Subject: [PATCH 14/14] Update t06_cinema.cpp --- src/main/cpp/t06_cinema.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/cpp/t06_cinema.cpp b/src/main/cpp/t06_cinema.cpp index 4a4e58903..77a66e302 100644 --- a/src/main/cpp/t06_cinema.cpp +++ b/src/main/cpp/t06_cinema.cpp @@ -29,7 +29,7 @@ using namespace std; int t06_cinema() { - int n, num, m, cou, row; + int n, num, m, cou=0, row=0; cin >> n >> m; int arr[n][m]; @@ -40,20 +40,21 @@ int t06_cinema() { } cin >> num; - for (int i = 0; i < n; i++){ - for (int j = 1; j < m; j++){ - if (arr[i][j] == 0){ - cou++; - if (cou == num){ - row = 1 + i; - break; - } - } - else { - cou = 0; + for (int i = 0; i < n; ++i) { + for (int j = 0; j < m; ++j) { + if (arr[i][j]==0) { + cou++; + } else {cou=0;} + if (cou == num) { + row= i+1; + break; } } - } - cout << row; + if (row>0) { + break; + } + cou=0; + } + cout << row; return 0; }