/
Nik135
/
Homeworks
Обзор
Документация
Войти
/
Nik135
/
Homeworks
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
b0.c
71 строка
1 KB
Nik135
дз
21 фев 2026, 21:34
Верифицирован
21 фев 2026, 21:34
bca67d5
Код
Авторство
О чём код?
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> typedef struct list { uint64_t address; size_t size; char comment[64]; struct list *next; } list; uint64_t findMaxBlock(list *head) { if (!head) return 0; uint64_t max_address = 0; size_t max_size = 0; for (list *cur = head; cur != NULL; cur = cur->next) { if (cur->size > max_size) { max_size = cur->size; max_address = cur->address; } } return max_address; } int main() { list *head = NULL; list *node; node = malloc(sizeof(list)); node->address = 140525067852320; node->size = 10; strcpy(node->comment, "Block 1"); node->next = head; head = node; node = malloc(sizeof(list)); node->address = 140525067852350; node->size = 30; strcpy(node->comment, "Block 2"); node->next = head; head = node; node = malloc(sizeof(list)); node->address = 140525067852900; node->size = 100; strcpy(node->comment, "Block 3"); node->next = head; head = node; uint64_t maxAddr = findMaxBlock(head); printf("Address of max block: %llu\n", maxAddr); while (head) { node = head; head = head->next; free(node); } return 0; }