From 3838100adda48994887be74f0de69b6a8a1eafad Mon Sep 17 00:00:00 2001 From: Yana Kalsina Date: Thu, 11 Dec 2025 13:12:36 +0300 Subject: [PATCH] Add file --- src/TasksOfLastTests/maxNumInArr.c | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/TasksOfLastTests/maxNumInArr.c diff --git a/src/TasksOfLastTests/maxNumInArr.c b/src/TasksOfLastTests/maxNumInArr.c new file mode 100644 index 0000000..611d34e --- /dev/null +++ b/src/TasksOfLastTests/maxNumInArr.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +int maxNumber(int* arr, int length) +{ + int maximum = 0; + for (int i = 0; i < length; i++) { + } +} + +int main() +{ + int* list = malloc(sizeof(int) * 100); + int i = 0; + int num = 0; + int count = 0; + printf("Введите числа (до 100 штук) через пробел и нажмите Enter:\n"); + while (1) { + int result = scanf("%d", &num); + if (result) { + list[i] = num; + count++; + } + // взяли из ввода следующий символ + int next_char = getchar(); + if (next_char == '\n') { + break; + } + // вернули его на место, если он не перенос строки + ungetc(next_char, stdin); + i++; + } + // тут где-то realloc + for (int i = 0; i < count; i++) { + printf("%d\n", list[i]); + } +}