уменьшить количество строк в коде язык программирования Паскаль оставив принцип роботы уже уменьшил с 486 до 255 либо подскажите как уменьшить количество строк
program krestiki_noliki;
uses
Crt, Graph;
var
g, key, i, s: Integer;
mas: array [1..9] of Integer;
procedure field;
begin
bar(100, 100, 620, 620);
bar(100, 273, 620, 446);
bar(273, 100, 446, 620);
end;
procedure reset;
begin
key := 2;
delay(1000);
cleardevice;
key := 0;
for i := 1 to 9 do
mas[i] := 0;
field
end;
procedure draw;
begin
for i := 1 to 9 do
s := s + mas[i];
if s = 13 then
begin
key := 2;
delay(1000);
reset;
end ;
end;
begin
InitGraph(detect, detect, '');
field;
while true do
begin
while key = 0 do
begin
g := readKey;
if (g = '1') and (mas[1] = 0) then
begin
line(130, 130, 243, 243);
line(243, 130, 130, 243);
key := 1;
mas[1] := 1;
end
else if (g = '2') and (mas[2] = 0) then
begin
line(303, 130, 416, 243);
line(416, 130, 303, 243);
key := 1;
mas[2] := 1;
end
else if (g = '3') and (mas[3] = 0) then
begin
line(476, 130, 590, 243);
line(590, 130, 476, 243);
key := 1;
mas[3] := 1;
end
else if (g = '4') and (mas[4] = 0) then
begin
line(130, 303, 243, 416);
line(243, 303, 130, 416);
key := 1;
mas[4] := 1;
end
else if (g = '5') and (mas[5] = 0) then
begin
line(303, 303, 416, 416);
line(416, 303, 303, 416);
key := 1;
mas[5] := 1;
end
else if (g = '6') and (mas[6] = 0) then
begin
line(476, 303, 590, 416);
line(590, 303, 476, 416);
key := 1;
mas[6] := 1;
end
else if (g = '7') and (mas[7] = 0) then
begin
line(130, 476, 243, 590);
line(243, 476, 130, 590);
key := 1;
mas[7] := 1;
end
else if (g = '8') and (mas[8] = 0) then
begin
line(303, 476, 416, 590);
line(416, 476, 303, 590);
key := 1;
mas[8] := 1;
end
else if (g = '9') and (mas[9] = 0) then
begin
line(476, 476, 590, 590);
line(590, 476, 476, 590);
key := 1;
mas[9] := 1;
end ;
s := 0;
if (mas[1] = 1) and (mas[2] = 1) and (mas[3] = 1) then
begin
line(130, 186, 590, 186);
reset;
end
else if (mas[4] = 1) and (mas[5] = 1) and (mas[6] = 1) then
begin
line(130, 359, 590, 359);
reset;
end
else if (mas[7] = 1) and (mas[8] = 1) and (mas[9] = 1) then
begin
line(130, 532, 590, 532);
reset;
end
else if (mas[1] = 1) and (mas[4] = 1) and (mas[7] = 1) then
begin
line(186, 130, 186, 590);
reset;
end
else if (mas[2] = 1) and (mas[5] = 1) and (mas[8] = 1) then
begin
line(359, 130, 359, 590);
reset;
end
else if (mas[3] = 1) and (mas[6] = 1) and (mas[9] = 1) then
begin
line(532, 130, 532, 590);
reset;
end
else if (mas[1] = 1) and (mas[5] = 1) and (mas[9] = 1) then
begin
line(130, 130, 590, 590);
reset;
end
else if (mas[3] = 1) and (mas[5] = 1) and (mas[7] = 1) then
begin
line(590, 130, 130, 590);
reset;
end ;
draw;
end;
while key = 1 do
begin
g := readkey;
if (g = '1') and (mas[1] = 0) then
begin
arc(186, 186, 0, 360, 56);
key := 0;
mas[1] := 2;
end
else if (g = '2') and (mas[2] = 0) then
begin
arc(359, 186, 0, 360, 56);
key := 0;
mas[2] := 2;
end
else if (g = '3') and (mas[3] = 0) then
begin
arc(532, 186, 0, 360, 56);
key := 0;
mas[3] := 2;
end
else if (g = '4') and (mas[4] = 0) then
begin
arc(186, 359, 0, 360, 56);
key := 0;
mas[4] := 2;
end
else if (g = '5') and (mas[5] = 0) then
begin
arc(359, 359, 0, 360, 56);
key := 0;
mas[5] := 2;
end
else if (g = '6') and (mas[6] = 0) then
begin
arc(532, 359, 0, 360, 56);
key := 0;
mas[6] := 2;
end
else if (g = '7') and (mas[7] = 0) then
begin
arc(186, 532, 0, 360, 56);
key := 0;
mas[7] := 2;
end
else if (g = '8') and (mas[8] = 0) then
begin
arc(359, 532, 0, 360, 56);
key := 0;
mas[8] := 2;
end
else if (g = '9') and (mas[9] = 0) then
begin
arc(532, 532, 0, 360, 56);
key := 0;
mas[9] := 2;
end ;
if (mas[1] = 2) and (mas[2] = 2) and (mas[3] = 2) then
begin
line(130, 186, 590, 186);
reset;
end
else if (mas[4] = 2) and (mas[5] = 2) and (mas[6] = 2) then
begin
line(130, 359, 590, 359);
reset;
end
else if (mas[7] = 2) and (mas[8] = 2) and (mas[9] = 2) then
begin
line(130, 532, 590, 532);
reset;
end
else if (mas[1] = 2) and (mas[4] = 2) and (mas[7] = 2) then
begin
line(186, 130, 186, 590);
reset;
end
else if (mas[2] = 2) and (mas[5] = 2) and (mas[8] = 2) then
begin
line(359, 130, 359, 590);
reset;
end
else if (mas[3] = 2) and (mas[6] = 2) and (mas[9] = 2) then
begin
line(532, 130, 532, 590);
reset;
end
else if (mas[1] = 2) and (mas[5] = 2) and (mas[9] = 2) then
begin
line(130, 130, 590, 590);
reset;
end
else if (mas[7] = 2) and (mas[5] = 2) and (mas[3] = 2) then
begin
line(590, 130, 130, 590);
reset;
end ;
end;
end;
end.
Файл с фамилиями и ростом прикреплён.
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
class People {
public:
string surname;
int height;
};
signed main() {
ifstream f;
People ppl[15];
int j = 0;
People newPpl;
try {
cout << "Input surname and height new people:\n";
cin >> newPpl.surname >> newPpl.height;
try {
f.open("guys.txt");
while (!f.eof()) {
f >> ppl[j].surname >> ppl[j].height;
j++;
}
}
catch (...) {
cout << "Error with file!";
}
int _minR = abs(newPpl.height - ppl[0].height);
string buff = ppl[0].surname;
for (int i = 0; i < 15; i++) {
if (abs(newPpl.height - ppl[i].height) < _minR) {
_minR = abs(newPpl.height - ppl[i].height);
buff = ppl[i].surname;
}
}
cout << endl << buff;
}
catch (...) {
cout << "Error in main programm!";
}
return 0;
}