Skip to content

Conversation

@Gadjib
Copy link
Owner

@Gadjib Gadjib commented Jan 5, 2024

No description provided.

Copy link

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пуллреквест удалит решения задач 7 и 9, чего быть не должно

Task 10-1/10-1.c Outdated
#include "road.h"

int main() {
int n, m, k;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Неинициализированные переменные нельзя
  • Сразу несколько переменных за раз не объявляйте

Task 10-1/10-1.c Outdated
int main() {
int n, m, k;
printf("Введите число городов и дорог: ");
scanf("%d %d", &n, &m);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В условии просили читать из файла

@@ -0,0 +1 @@
gcc -Wall -Werror 10-1.c road.c No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо что-то более кроссплатформенное как описание сборки

Task 10-1/road.c Outdated
#include <stdlib.h>
#include <limits.h>

// Функция для нахождения ближайшего незанятого города к заданному городу

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Файлы .c интересны тем, кто их поддерживает, тогда как файлы .h интересны всем, кто хочет использовать код модуля. Поэтому комментарии должны быть в .h

Task 10-1/road.c Outdated
int currentCity = findNearestUnassignedCity(distances, assigned, n);
int currentState = assigned[currentCity];

printf("Государство %d: %d ", currentState, currentCity);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Код, делающий полезную работу, никогда не должен выводить на консоль или читать с консоли. Это делает невозможным переиспользование и модульное тестирование.

Task 10-1/road.c Outdated
// Функция для распределения городов между государствами
void distributeCities(int n, int m, struct Road *roads, int k, int *capitals) {
// Инициализация массива расстояний и массива, указывающего на принадлежность государству
int *distances = (int *)malloc(n * sizeof(int));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Расстояний до чего? Государства по очереди захватывают ближайший к ним город

Task 10-1/road.h Outdated
Comment on lines 2 to 4
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В заголовочном файле подключается только то, что нужно в заголовочном файле. Всё остальное подключается в .c-шнике

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants