-
Notifications
You must be signed in to change notification settings - Fork 0
Task10 1 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
yurii-litvinov
left a comment
There was a problem hiding this 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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В условии просили читать из файла
Task 10-1/build.sh
Outdated
| @@ -0,0 +1 @@ | |||
| gcc -Wall -Werror 10-1.c road.c No newline at end of file | |||
There was a problem hiding this comment.
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> | ||
|
|
||
| // Функция для нахождения ближайшего незанятого города к заданному городу |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <limits.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В заголовочном файле подключается только то, что нужно в заголовочном файле. Всё остальное подключается в .c-шнике
No description provided.