![]() |
1. Заголовок темы должен быть информативным. В противном случае тема удаляется ...
2. Все тексты программ должны помещаться в теги [code=pas] ... [/code].
3. Прежде чем задавать вопрос, см. "FAQ", если там не нашли ответа, воспользуйтесь ПОИСКОМ, возможно такую задачу уже решали!
4. Не предлагайте свои решения на других языках, кроме Паскаля (исключение - только с согласия модератора).
5. НЕ используйте форум для личного общения, все что не относится к обсуждению темы - на PM!
6. Одна тема - один вопрос (задача)
7. Проверяйте программы перед тем, как разместить их на форуме!!!
8. Спрашивайте и отвечайте четко и по существу!!!
![]() |
Tenshi |
![]() ![]()
Сообщение
#1
|
Новичок ![]() Группа: Пользователи Сообщений: 20 Пол: Мужской Реальное имя: Artem Репутация: ![]() ![]() ![]() |
В парламенте острова Невезения каждый из N = 6 депутатов имеет не более М = 2 врагов. ( Если А - враг Б, то Б - враг А). Для уменьшения разногласий президент решил преобразовать парламент в двухпалатный.
Составить программу, которая проверяет, можно ли парламент разделить на две палаты так, что быу каждого депутата в своей палате было не более М врагов. |
![]() ![]() |
Tenshi |
![]()
Сообщение
#2
|
Новичок ![]() Группа: Пользователи Сообщений: 20 Пол: Мужской Реальное имя: Artem Репутация: ![]() ![]() ![]() |
Код program omg; type enemy= set of 'a'..'f'; var is_enemy:enemy; a,b,c,d,e,f,m:integer; a_enemies: integer; b_enemies: integer; c_enemies: integer; d_enemies: integer; e_enemies: integer; f_enemies: integer; procedure sortirovka; begin for a:=1 to 2 do for b:=1 to 2 do for c:=1 to 2 do for d:=1 to 2 do for e:=1 to 2 do for f:=1 to 2 do begin a_enemies:=0; if (a = b) and (is_enemy[a,b]) the inc(a_enemies); if (a = c) and (is_enemy[a,c]) the inc(a_enemies); if (a = d) and (is_enemy[a,d]) the inc(a_enemies); if (a = e) and (is_enemy[a,e]) the inc(a_enemies); if (a = f) and (is_enemy[a,f]) the inc(a_enemies); if a_enemies > m then continue; b_enemies:=0; if (b = a) and (is_enemy[b,a]) the inc(b_enemies); if (b = c) and (is_enemy[b,c]) the inc(b_enemies); if (b = d) and (is_enemy[b,d]) the inc(b_enemies); if (b = e) and (is_enemy[b,e]) the inc(b_enemies); if (b = f) and (is_enemy[b,f]) the inc(b_enemies); if b_enemies > m then continue; c_enemies:=0; if (c = a) and (is_enemy[c,a]) the inc(c_enemies); if (c = b) and (is_enemy[c,b]) the inc(c_enemies); if (c = d) and (is_enemy[c,d]) the inc(c_enemies); if (c = e) and (is_enemy[c,e]) the inc(c_enemies); if (c = f) and (is_enemy[c,f]) the inc(c_enemies); if c_enemies > m then continue; c_enemies:=0; if (d = a) and (is_enemy[d,a]) the inc(d_enemies); if (d = b) and (is_enemy[d,b]) the inc(d_enemies); if (d = c) and (is_enemy[d,c]) the inc(d_enemies); if (d = e) and (is_enemy[d,e]) the inc(d_enemies); if (d = f) and (is_enemy[d,f]) the inc(d_enemies); if d_enemies > m then continue; e_enemies:=0; if (e = a) and (is_enemy[e,a]) the inc(e_enemies); if (e = b) and (is_enemy[e,b]) the inc(e_enemies); if (e = c) and (is_enemy[e,c]) the inc(e_enemies); if (e = d) and (is_enemy[e,d]) the inc(e_enemies); if (e = f) and (is_enemy[e,f]) the inc(e_enemies); if e_enemies > m then continue; f_enemies:=0; if (f = a) and (is_enemy[f,a]) the inc(f_enemies); if (f = b) and (is_enemy[f,b]) the inc(f_enemies); if (f = c) and (is_enemy[f,c]) the inc(f_enemies); if (f = e) and (is_enemy[f,e]) the inc(f_enemies); if (f = d) and (is_enemy[f,d]) the inc(f_enemies); if f_enemies > m then continue; end; begin Writeln ('Kolichestvo vragov m: ',m); Readln (m); Sortirovka; end. Посмотрите пожалуйста где касяки и как вывести результат. Код не работает (В основном конечно из-за прямоты рук >_<) |
![]() ![]() |
![]() |
Текстовая версия | 18.07.2025 14:22 |