diff --git "a/\352\263\274\354\240\234/inq_atoi.md" "b/\352\263\274\354\240\234/inq_atoi.md" index 68fcaaf..09a666c 100644 --- "a/\352\263\274\354\240\234/inq_atoi.md" +++ "b/\352\263\274\354\240\234/inq_atoi.md" @@ -35,7 +35,6 @@ - 테스트 목적으로 사용하는 것은 허용하나, 제출 파일 및 함수 구현 과정에서는 절대 포함할 수 없습니다. - 함정이 있어요! - **정수 최댓값, 최솟값 리턴을 어떻게 할지 고심해보세요.** - - INT_MAX를 초과하는 값이나, INT_MIN 미만의 값이 input될 경우, overflow와 underflow를 자연스럽게 처리해야 합니다. - (사용하지는 않겠지만) malloc을 사용할 경우, Memory Leak은 허용하지 않습니다. - 전역변수 사용이 금지됩니다. 함수 분리, 메서드 분리는 지역 변수를 이용하여 parameter로 처리하세요. - 전체 함수 및 메서드는 `int inq_atoi(char *str)`함수를 포함해 5개 이하로 작성하세요. diff --git "a/\354\235\264\354\203\201\355\230\204/Week 5/Week5_1475.c" "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_1475.c" new file mode 100644 index 0000000..976d875 --- /dev/null +++ "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_1475.c" @@ -0,0 +1,27 @@ +#include + +int main() +{ + int a, sum, max; + int d[10] = {0}; + scanf("%d", &a); + while (a > 0) + { + sum = a % 10; + d[sum]++; + a /= 10; + } + + max = (d[6] + d[9] + 1) / 2; + + for (int i = 0; i < 10; i++) + { + if (i == 6 || i == 9) + continue; + else if (d[i] > max) + { + max = d[i]; + } + } + printf("%d",max); +} \ No newline at end of file diff --git "a/\354\235\264\354\203\201\355\230\204/Week 5/Week5_2577.c" "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_2577.c" new file mode 100644 index 0000000..54f537e --- /dev/null +++ "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_2577.c" @@ -0,0 +1,21 @@ +#include + +int main() +{ + + int A, B, C, sum, res; + int a[10] = { 0 }; + scanf("%d %d %d", &A, &B, &C); + sum = A * B * C; + + while (sum >0) { + res = sum % 10; + a[res]++; + sum /= 10; + } + for (int i = 0; i < 10; i++) + { + printf("%d\n", a[i]); + } + +} \ No newline at end of file diff --git "a/\354\235\264\354\203\201\355\230\204/Week 5/Week5_3273.c" "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_3273.c" new file mode 100644 index 0000000..214c40e --- /dev/null +++ "b/\354\235\264\354\203\201\355\230\204/Week 5/Week5_3273.c" @@ -0,0 +1,52 @@ +#include +#include + +int compare(const void* a, const void* b) { + return (*(int*)a - *(int*)b); +} + +int countPairs(int* sequence, int n, int x) { + int count = 0; + int i = 0; + int j = n - 1; + + while (i < j) { + if (sequence[i] + sequence[j] == x) { + count++; + i++; + j--; + } + else if (sequence[i] + sequence[j] < x) { + i++; + } + else { + j--; + } + } + + return count; +} + +int main() { + int n; + scanf("%d", &n); + + int* sequence = (int*)malloc(n * sizeof(int)); + if (sequence == NULL) { + return 1; + } + + for (int i = 0; i < n; i++) { + scanf("%d", &sequence[i]); + } + + int x; + scanf("%d", &x); + qsort(sequence, n, sizeof(int), compare); + int result = countPairs(sequence, n, x); + printf("%d\n", result); + + free(sequence); + + return 0; +} \ No newline at end of file