From dc7a8566fe9a593b7d490955cd41f6cb92a9b3e7 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:39:28 +0900 Subject: [PATCH 01/12] =?UTF-8?q?Create=201157=EB=B2=88=20-=20=EB=8B=A8?= =?UTF-8?q?=EC=96=B4=EA=B0=9C=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\250\354\226\264\352\260\234\354\210\230" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" diff --git "a/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" "b/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" new file mode 100644 index 0000000..6176972 --- /dev/null +++ "b/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" @@ -0,0 +1,27 @@ +#include +#include + +int main() { + int count[26] = {0}; + char word[1000001]; + char most_used = '?'; + int max_count = 0; + + scanf("%s", word); + for (int i = 0; word[i] != '\0'; i++) { + if (isalpha(word[i])) { + int index = tolower(word[i]) - 'a'; + count[index]++; + if (count[index] > max_count) { + max_count = count[index]; + most_used = toupper(word[i]); + } else if (count[index] == max_count) { + most_used = '?'; + } + } + } + + printf("%c\n", most_used); + + return 0; +} From 2a186cd1e684aaea8021f5cd53edd12701d7e8e8 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:09:05 +0900 Subject: [PATCH 02/12] =?UTF-8?q?Create=202439=EB=B2=88=20-=20=EB=B3=84=20?= =?UTF-8?q?=EC=B0=8D=EA=B8=B0=20-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \353\263\204 \354\260\215\352\270\260 -2" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "202202545/2439\353\262\210 - \353\263\204 \354\260\215\352\270\260 -2" diff --git "a/202202545/2439\353\262\210 - \353\263\204 \354\260\215\352\270\260 -2" "b/202202545/2439\353\262\210 - \353\263\204 \354\260\215\352\270\260 -2" new file mode 100644 index 0000000..a3f9598 --- /dev/null +++ "b/202202545/2439\353\262\210 - \353\263\204 \354\260\215\352\270\260 -2" @@ -0,0 +1,25 @@ +#include + +int main() { + int n; + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + int space = n - i; + + // 공백 출력 + for (int j = 0; j < space; j++) { + printf(" "); + } + + // 별 출력 + for (int k = 0; k < i; k++) { + printf("*"); + } + + // 줄 바꿈 + printf("\n"); + } + + return 0; +} From b3cb00e1c14513e868a3f9fa8950cc2407422115 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:12:15 +0900 Subject: [PATCH 03/12] =?UTF-8?q?Create=2011720=EB=B2=88=20-=20=EC=88=AB?= =?UTF-8?q?=EC=9E=90=EC=9D=98=20=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\253\354\236\220\354\235\230 \355\225\251" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "202202545/11720\353\262\210 - \354\210\253\354\236\220\354\235\230 \355\225\251" diff --git "a/202202545/11720\353\262\210 - \354\210\253\354\236\220\354\235\230 \355\225\251" "b/202202545/11720\353\262\210 - \354\210\253\354\236\220\354\235\230 \355\225\251" new file mode 100644 index 0000000..0d8131d --- /dev/null +++ "b/202202545/11720\353\262\210 - \354\210\253\354\236\220\354\235\230 \355\225\251" @@ -0,0 +1,18 @@ +#include + +int main() { + int N; + char number[101]; + + scanf("%d", &N); + scanf("%s", number); + + int sum = 0; + for (int i = 0; i < N; i++) { + sum += number[i] - '0'; + } + + printf("%d\n", sum); + + return 0; +} From f66dae0fe79f612d4331bd1cd4c13655bd957e95 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:30:05 +0900 Subject: [PATCH 04/12] =?UTF-8?q?refactor:=20=ED=8F=B4=EB=8D=94=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...53\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" => "202202545/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" (100%) diff --git "a/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" "b/202202545/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" similarity index 100% rename from "1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" rename to "202202545/1157\353\262\210 - \353\213\250\354\226\264\352\260\234\354\210\230" From d415e2f71da07ff6330dfe807032e96d34659181 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:01:32 +0900 Subject: [PATCH 05/12] =?UTF-8?q?Create=2010818=EB=B2=88=20-=20=EC=B5=9C?= =?UTF-8?q?=EB=8C=80,=EC=B5=9C=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\234\353\214\200,\354\265\234\354\206\214" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "202202545/10818\353\262\210 - \354\265\234\353\214\200,\354\265\234\354\206\214" diff --git "a/202202545/10818\353\262\210 - \354\265\234\353\214\200,\354\265\234\354\206\214" "b/202202545/10818\353\262\210 - \354\265\234\353\214\200,\354\265\234\354\206\214" new file mode 100644 index 0000000..4e676dd --- /dev/null +++ "b/202202545/10818\353\262\210 - \354\265\234\353\214\200,\354\265\234\354\206\214" @@ -0,0 +1,23 @@ +#include + +int main() { + int N; + int min_value = 1000000; + int max_value = -1000000; + + scanf("%d", &N); + + for (int i = 0; i < N; i++) { + int num; + scanf("%d", &num); + + if (num < min_value) + min_value = num; + if (num > max_value) + max_value = num; + } + + printf("%d %d\n", min_value, max_value); + + return 0; +} From c1e89848ae621ed9a9298ac4fed92070998c1f78 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:09:34 +0900 Subject: [PATCH 06/12] =?UTF-8?q?Create=208958=EB=B2=88=20-=20ox=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\262\210 - ox\353\254\270\354\240\234" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "202202545/8958\353\262\210 - ox\353\254\270\354\240\234" diff --git "a/202202545/8958\353\262\210 - ox\353\254\270\354\240\234" "b/202202545/8958\353\262\210 - ox\353\254\270\354\240\234" new file mode 100644 index 0000000..3e4928b --- /dev/null +++ "b/202202545/8958\353\262\210 - ox\353\254\270\354\240\234" @@ -0,0 +1,29 @@ +#include +#include + +int main() { + int num_tests; + char result[81]; + + scanf("%d", &num_tests); + + for (int i = 0; i < num_tests; i++) { + scanf("%s", result); + + int score = 0; + int combo = 0; + + for (int j = 0; j < strlen(result); j++) { + if (result[j] == 'O') { + combo++; + score += combo; + } else { + combo = 0; + } + } + + printf("%d\n", score); + } + + return 0; +} From ffeecd7bd3cd2cc24e4f3ead501f8df8455df293 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Thu, 2 May 2024 13:19:55 +0900 Subject: [PATCH 07/12] aa --- ...3\250\354\226\264\354\240\225\353\240\254" | 42 +++++++++++++++++++ ...\214\353\262\263 \354\260\276\352\270\260" | 26 ++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 "1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" create mode 100644 "202202545/10809\353\262\210 - \354\225\214\355\214\214\353\262\263 \354\260\276\352\270\260" diff --git "a/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" "b/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" new file mode 100644 index 0000000..e979f61 --- /dev/null +++ "b/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" @@ -0,0 +1,42 @@ +#include +#include +#include + +struct Word { + char str[51]; +}; + +// 비교 +int compare(const void *a, const void *b) { + struct Word *wordA = (struct Word *)a; + struct Word *wordB = (struct Word *)b; + + // 길이가 다르면 길이 오름차순 정렬 + if (strlen(wordA->str) != strlen(wordB->str)) { + return strlen(wordA->str) - strlen(wordB->str); + } else { // 길이가 같으면 사전 순으로 정렬 + return strcmp(wordA->str, wordB->str); + } +} + +int main() { + int N; + scanf("%d", &N); + + struct Word words[N]; + + for (int i = 0; i < N; i++) { + scanf("%s", words[i].str); + } + + qsort(words, N, sizeof(struct Word), compare); + + printf("%s\n", words[0].str); + for (int i = 1; i < N; i++) { + if (strcmp(words[i].str, words[i - 1].str) != 0) { + printf("%s\n", words[i].str); + } + } + + return 0; +} \ No newline at end of file diff --git "a/202202545/10809\353\262\210 - \354\225\214\355\214\214\353\262\263 \354\260\276\352\270\260" "b/202202545/10809\353\262\210 - \354\225\214\355\214\214\353\262\263 \354\260\276\352\270\260" new file mode 100644 index 0000000..cdeac56 --- /dev/null +++ "b/202202545/10809\353\262\210 - \354\225\214\355\214\214\353\262\263 \354\260\276\352\270\260" @@ -0,0 +1,26 @@ +#include +#include + +int main() { + char word[101]; + int positions[26]; + + scanf("%s", word); + + // 모든 알파벳의 등장 위치 -1로 초기화 + memset(positions, -1, sizeof(positions)); + + for (int i = 0; word[i] != '\0'; i++) { + int index = word[i] - 'a'; // 알파벳 인덱스 계산 + if (positions[index] == -1) { + positions[index] = i; + } + } + + // 결과 출력 + for (int i = 0; i < 26; i++) { + printf("%d ", positions[i]); + } + + return 0; +} From 77a9739cbf7568a5a0d9903a1e47d3075c034b54 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sat, 4 May 2024 21:04:29 +0900 Subject: [PATCH 08/12] move in --- ...53\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" => "202202545/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" (100%) diff --git "a/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" "b/202202545/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" similarity index 100% rename from "1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" rename to "202202545/1181\353\262\210 - \353\213\250\354\226\264\354\240\225\353\240\254" From 499cfc6a979f297b9db6d428181876b637c00c49 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sun, 5 May 2024 07:19:27 +0900 Subject: [PATCH 09/12] =?UTF-8?q?Create=202751=EB=B2=88=20-=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\225\353\240\254\355\225\230\352\270\2602" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "202202545/2751\353\262\210 - \354\210\230\354\240\225\353\240\254\355\225\230\352\270\2602" diff --git "a/202202545/2751\353\262\210 - \354\210\230\354\240\225\353\240\254\355\225\230\352\270\2602" "b/202202545/2751\353\262\210 - \354\210\230\354\240\225\353\240\254\355\225\230\352\270\2602" new file mode 100644 index 0000000..47f4993 --- /dev/null +++ "b/202202545/2751\353\262\210 - \354\210\230\354\240\225\353\240\254\355\225\230\352\270\2602" @@ -0,0 +1,25 @@ +#include +#include + +int compare(const void *a, const void *b) { + return (*(int *)a - *(int *)b); +} + +int main() { + int N; + scanf("%d", &N); + + int nums[N]; + + for (int i = 0; i < N; i++) { + scanf("%d", &nums[i]); + } + + qsort(nums, N, sizeof(int), compare); + + for (int i = 0; i < N; i++) { + printf("%d\n", nums[i]); + } + + return 0; +} From aebb9d5de38accd050aa35c54509a47926a9865e Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sun, 5 May 2024 07:24:42 +0900 Subject: [PATCH 10/12] =?UTF-8?q?Create=201929=EB=B2=88=20-=20=EC=86=8C?= =?UTF-8?q?=EC=88=98=20=EA=B5=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\230 \352\265\254\355\225\230\352\270\260" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "202202545/1929\353\262\210 - \354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260" diff --git "a/202202545/1929\353\262\210 - \354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260" "b/202202545/1929\353\262\210 - \354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260" new file mode 100644 index 0000000..aee4c9f --- /dev/null +++ "b/202202545/1929\353\262\210 - \354\206\214\354\210\230 \352\265\254\355\225\230\352\270\260" @@ -0,0 +1,27 @@ +#include +#include + +bool is_prime(int n) { + if (n <= 1) return false; + if (n <= 3) return true; + if (n % 2 == 0 || n % 3 == 0) return false; + + for (int i = 5; i * i <= n; i += 6) { + if (n % i == 0 || n % (i + 2) == 0) return false; + } + + return true; +} + +int main() { + int M, N; + scanf("%d %d", &M, &N); + + for (int i = M; i <= N; i++) { + if (is_prime(i)) { + printf("%d\n", i); + } + } + + return 0; +} From d2d4fd3a316672eef7b84788f29fb656b9c6fcfb Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sun, 12 May 2024 18:24:51 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=EC=97=B4=EC=8B=AC=ED=9E=88=20=ED=92=80?= =?UTF-8?q?=EC=97=87=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\234 \354\271\240\355\225\230\352\270\260" | 76 +++++++++++++++++++ ...46\353\262\210 - \355\217\211\352\267\240" | 34 +++++++++ "202202545/18110\353\262\210 - solved.ac" | 44 +++++++++++ ...4\353\262\210 - \354\271\264\353\223\2342" | 30 ++++++++ ...\244\355\203\225 \353\260\260\353\213\254" | 30 ++++++++ 5 files changed, 214 insertions(+) create mode 100644 "202202545/1018\353\262\210 - \354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260" create mode 100644 "202202545/1546\353\262\210 - \355\217\211\352\267\240" create mode 100644 "202202545/18110\353\262\210 - solved.ac" create mode 100644 "202202545/2164\353\262\210 - \354\271\264\353\223\2342" create mode 100644 "202202545/2839\353\262\210 - \354\204\244\355\203\225 \353\260\260\353\213\254" diff --git "a/202202545/1018\353\262\210 - \354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260" "b/202202545/1018\353\262\210 - \354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260" new file mode 100644 index 0000000..2fdf9f7 --- /dev/null +++ "b/202202545/1018\353\262\210 - \354\262\264\354\212\244\355\214\220 \353\213\244\354\213\234 \354\271\240\355\225\230\352\270\260" @@ -0,0 +1,76 @@ +#include +#include +#include +#include +using namespace std; +string WB[8] = { + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW" +}; +string BW[8] = { + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB", + "BWBWBWBW", + "WBWBWBWB" +}; +string board[50]; +int WB_cnt(int x, int y) +{ + int cnt = 0; + for(int i = 0; i < 8; i++) + { + for(int j = 0; j < 8; j++) + { + if(board[x+i][y+j] != WB[i][j]) + cnt++; + } + + } + return cnt; +} +int BW_cnt(int x, int y) +{ + int cnt = 0; + for(int i = 0; i < 8; i++) + { + for(int j = 0; j < 8; j++) + { + if(board[x+i][y+j] != BW[i][j]) + cnt++; + } + + } + return cnt; +} +int main() { + int size[2]; + int cnt; + int min_val = 12345; + pair p1; + cin >> p1.first >> p1.second; + for(int i = 0; i < p1.first; i++) + cin >> board[i]; + for(int i = 0; i + 8 <= p1.first; i++) + { + for(int j = 0; j + 8 <= p1.second; j++) + { + int tmp; + tmp = min(WB_cnt(i,j),BW_cnt(i,j)); + if(tmp < min_val) { + min_val = tmp; + } + } + } + cout << min_val; + return 0; +} \ No newline at end of file diff --git "a/202202545/1546\353\262\210 - \355\217\211\352\267\240" "b/202202545/1546\353\262\210 - \355\217\211\352\267\240" new file mode 100644 index 0000000..e0d8070 --- /dev/null +++ "b/202202545/1546\353\262\210 - \355\217\211\352\267\240" @@ -0,0 +1,34 @@ +#include +#include + +int main() { + int N; + scanf("%d", &N); + + int *scores = (int *)malloc(N * sizeof(int)); + if (scores == NULL) { + fprintf(stderr, "메모리 할당 오류\n"); + return 1; + } + + int max_score = 0; + + for (int i = 0; i < N; i++) { + scanf("%d", &scores[i]); + if (scores[i] > max_score) { + max_score = scores[i]; + } + } + + double sum = 0; + for (int i = 0; i < N; i++) { + sum += ((double)scores[i] / max_score) * 100; + } + + printf("%.6lf\n", sum / N); + + free(scores); // 동적으로 할당한 메모리 해제 + + return 0; +} + diff --git "a/202202545/18110\353\262\210 - solved.ac" "b/202202545/18110\353\262\210 - solved.ac" new file mode 100644 index 0000000..468d2cb --- /dev/null +++ "b/202202545/18110\353\262\210 - solved.ac" @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include + +using namespace std; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n; + int res = 0; + + cin >> n; + + if (n == 0) + { + cout << res; + return 0; + } + + vector numbers(n); + + for (int i = 0; i < n; i++) + cin >> numbers[i]; + + sort(numbers.begin(), numbers.end()); + + int idx = round(n * 0.15); + double sum = 0; + + for (int i = idx; i < n - idx; i++) + sum += numbers[i]; + + res = round(sum / (n - idx * 2)); + + cout << res; + + return 0; +} diff --git "a/202202545/2164\353\262\210 - \354\271\264\353\223\2342" "b/202202545/2164\353\262\210 - \354\271\264\353\223\2342" new file mode 100644 index 0000000..4bdf0fc --- /dev/null +++ "b/202202545/2164\353\262\210 - \354\271\264\353\223\2342" @@ -0,0 +1,30 @@ +#include +#include + +using namespace std; + +int main(int argc, char**argv) { + + ios::sync_with_stdio(0); + cin.tie(0); + + queue Q; + int N; + + cin >> N; + + for(int i=1;i<=N;i++){ + Q.push(i); + } + + + while(Q.size()>1){ + Q.pop(); + Q.push(Q.front()); + Q.pop(); + } + + cout << Q.front(); + + return 0; +} \ No newline at end of file diff --git "a/202202545/2839\353\262\210 - \354\204\244\355\203\225 \353\260\260\353\213\254" "b/202202545/2839\353\262\210 - \354\204\244\355\203\225 \353\260\260\353\213\254" new file mode 100644 index 0000000..6aa7b9a --- /dev/null +++ "b/202202545/2839\353\262\210 - \354\204\244\355\203\225 \353\260\260\353\213\254" @@ -0,0 +1,30 @@ +#include + +int main() { + int N; + scanf("%d", &N); + + int bag5 = N / 5; + int remainder = N % 5; + + int bag3 = 0; + + if (remainder != 0) { + while (bag5 >= 0) { + if (remainder % 3 == 0) { + bag3 = remainder / 3; + break; + } + bag5--; + remainder += 5; + } + } + + if (bag5 < 0) { + printf("-1\n"); + } else { + printf("%d\n", bag5 + bag3); + } + + return 0; +} From 73eccb9d8c216a59bd9cbc1c2a2caa51f000d161 Mon Sep 17 00:00:00 2001 From: gy8879 <99649795+gy8879@users.noreply.github.com> Date: Sun, 19 May 2024 21:23:54 +0900 Subject: [PATCH 12/12] yeolgong --- "10845\353\262\210 - \355\201\220" | 80 +++++++++++++++++++ ...70\354\212\244 \353\254\270\354\240\234 0" | 31 +++++++ ...5\264\354\210\234\354\240\225\353\240\254" | 43 ++++++++++ ...28\353\262\210 - \354\212\244\355\203\235" | 75 +++++++++++++++++ "2920\353\262\210 -\354\235\214\352\263\204" | 30 +++++++ 5 files changed, 259 insertions(+) create mode 100644 "10845\353\262\210 - \355\201\220" create mode 100644 "11866\353\262\210 - \354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0" create mode 100644 "202202545/10814\353\262\210 - \353\202\230\354\235\264\354\210\234\354\240\225\353\240\254" create mode 100644 "202202545/10828\353\262\210 - \354\212\244\355\203\235" create mode 100644 "2920\353\262\210 -\354\235\214\352\263\204" diff --git "a/10845\353\262\210 - \355\201\220" "b/10845\353\262\210 - \355\201\220" new file mode 100644 index 0000000..150d069 --- /dev/null +++ "b/10845\353\262\210 - \355\201\220" @@ -0,0 +1,80 @@ +#include +#include +#include + +#define MAX_QUEUE_SIZE 10000 + +typedef struct { + int data[MAX_QUEUE_SIZE]; + int front; + int back; +} Queue; + +void initQueue(Queue *q) { + q->front = 0; + q->back = 0; +} + +int isEmpty(Queue *q) { + return q->front == q->back; +} + +int size(Queue *q) { + return q->back - q->front; +} + +void push(Queue *q, int value) { + q->data[q->back++] = value; +} + +int pop(Queue *q) { + if (isEmpty(q)) { + return -1; + } + return q->data[q->front++]; +} + +int front(Queue *q) { + if (isEmpty(q)) { + return -1; + } + return q->data[q->front]; +} + +int back(Queue *q) { + if (isEmpty(q)) { + return -1; + } + return q->data[q->back - 1]; +} + +int main() { + int n; + scanf("%d", &n); + + Queue q; + initQueue(&q); + + for (int i = 0; i < n; i++) { + char command[6]; + scanf("%s", command); + + if (strcmp(command, "push") == 0) { + int value; + scanf("%d", &value); + push(&q, value); + } else if (strcmp(command, "pop") == 0) { + printf("%d\n", pop(&q)); + } else if (strcmp(command, "size") == 0) { + printf("%d\n", size(&q)); + } else if (strcmp(command, "empty") == 0) { + printf("%d\n", isEmpty(&q)); + } else if (strcmp(command, "front") == 0) { + printf("%d\n", front(&q)); + } else if (strcmp(command, "back") == 0) { + printf("%d\n", back(&q)); + } + } + + return 0; +} diff --git "a/11866\353\262\210 - \354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0" "b/11866\353\262\210 - \354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0" new file mode 100644 index 0000000..8a6b6a3 --- /dev/null +++ "b/11866\353\262\210 - \354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234 0" @@ -0,0 +1,31 @@ +#include + +int main(void) +{ + int n, k, i; + scanf("%d%d", &n, &k); + int a[n+1]; + for(i = 1; i<=n; i++) a[i]=1; + + printf("<"); + i=1; + int count = 0; + int count_k = 0; + while(1) + { + if(a[i] == 1) count_k++; + if(a[i] == 1 && count_k == k) { + count_k = 0; + a[i] = 0; + count++; + if(count == n) { + printf("%d>", i); + break; + } + printf("%d, ", i); + } + i++; + if(i>n) i = i-n; + } + return 0; +} \ No newline at end of file diff --git "a/202202545/10814\353\262\210 - \353\202\230\354\235\264\354\210\234\354\240\225\353\240\254" "b/202202545/10814\353\262\210 - \353\202\230\354\235\264\354\210\234\354\240\225\353\240\254" new file mode 100644 index 0000000..b0dcac0 --- /dev/null +++ "b/202202545/10814\353\262\210 - \353\202\230\354\235\264\354\210\234\354\240\225\353\240\254" @@ -0,0 +1,43 @@ +#include +#include +#include + +// 회원 구조체 정의 +typedef struct { + int age; + char name[101]; + int order; // 가입 순서를 저장하는 필드 +} Member; + +int compare(const void *a, const void *b) { + Member *memberA = (Member *)a; + Member *memberB = (Member *)b; + + if (memberA->age != memberB->age) { + return memberA->age - memberB->age; // 나이 오름차순 정렬 + } else { + return memberA->order - memberB->order; // 가입 순서 오름차순 정렬 + } +} + +int main() { + int N; + scanf("%d", &N); // 회원의 수 입력 + + Member *members = (Member *)malloc(N * sizeof(Member)); // 동적 메모리 할당 + + for (int i = 0; i < N; i++) { + scanf("%d %s", &members[i].age, members[i].name); + members[i].order = i; // 가입 순서 저장 + } + + qsort(members, N, sizeof(Member), compare); + + for (int i = 0; i < N; i++) { + printf("%d %s\n", members[i].age, members[i].name); + } + + free(members); + + return 0; +} diff --git "a/202202545/10828\353\262\210 - \354\212\244\355\203\235" "b/202202545/10828\353\262\210 - \354\212\244\355\203\235" new file mode 100644 index 0000000..6321fbd --- /dev/null +++ "b/202202545/10828\353\262\210 - \354\212\244\355\203\235" @@ -0,0 +1,75 @@ +#include +#include +#define stack_size 10001 + +int high = -1; +int stack[stack_size]; + +void push(int x) +{ + high++; + stack[high] = x; +} +int empty() +{ + if (high == -1) + return 1; + else + return 0; +} +int pop() +{ + if (empty()) + { + return -1; + } + else + { + return stack[high--]; + } +} +int top() +{ + if (empty()) + return -1; + else + return stack[high]; +} +int main() +{ + + int N = 0, push_data = 0; + char command[5] = {0, }; + + scanf("%d", &N); + + for (int i = 0; i < N; i++) + { + + scanf("%s", command); + + if (!strcmp(command, "push")) + { + scanf("%d", &push_data); + push(push_data); + } + else if (!strcmp(command, "pop")) + { + printf("%d\n", pop()); + } + else if (!strcmp(command, "empty")) + { + printf("%d\n", empty()); + } + else if (!strcmp(command, "size")) + { + printf("%d\n", high + 1); + } + else if (!strcmp(command, "top")) + { + printf("%d\n", top()); + } + } + + return 0; +} \ No newline at end of file diff --git "a/2920\353\262\210 -\354\235\214\352\263\204" "b/2920\353\262\210 -\354\235\214\352\263\204" new file mode 100644 index 0000000..053247a --- /dev/null +++ "b/2920\353\262\210 -\354\235\214\352\263\204" @@ -0,0 +1,30 @@ +#include + +int main() { + int notes[8]; + + for (int i = 0; i < 8; i++) { + scanf("%d", ¬es[i]); + } + + int ascending = 1; + int descending = 1; + + for (int i = 0; i < 7; i++) { + if (notes[i] < notes[i + 1]) { + descending = 0; + } else if (notes[i] > notes[i + 1]) { + ascending = 0; + } + } + + if (ascending) { + printf("ascending\n"); + } else if (descending) { + printf("descending\n"); + } else { + printf("mixed\n"); + } + + return 0; +}