М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
sabina300
sabina300
29.04.2021 22:37 •  Информатика

уменьшить количество строк в коде язык программирования Паскаль оставив принцип роботы уже уменьшил с 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.​

👇
Открыть все ответы
Ответ:
GEgor004
GEgor004
29.04.2021

Файл с фамилиями и ростом прикреплён.

#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;

}


Решить в с++ Известны данные о росте 15-ти юношей класса, упорядоченные по убыванию. Нет ни одной па
4,7(3 оценок)
Ответ:
ArtGame23
ArtGame23
29.04.2021

написал на с++

Объяснение:

#include <iostream>

#include <windows.h>//для русской раскладки

using namespace std;

int main()

{

SetConsoleCP(1251);//подключаем русскую раскладку

SetConsoleOutputCP(1251);

float a[3][4]; //двумерный массив

cout << "Введите элементы массива:" << endl;

for (int i = 0; i < 3; i++)

{

 for (int j = 0; j < 4; j++)

 {

  cout << "a[" << i + 1 << "][" << j + 1 << "]= ";

  cin >> a[i][j];

 }

}

cout << "Введенная матрица до изменения:" << endl; //вывод матрицы B

for (int i = 0; i < 3; i++)

{

 for (int j = 0; j < 4; j++)

 {

  cout.width(7);// выравниваем числа по7 позиций

  cout << a[i][j];

 }

 cout << endl;

}

for (int i = 0; i < 3; i++)

{

 for (int j = 0; j < 4; j++)

 {

  if (a[i][j] == 0)

   a[i][j] = 10;

 }

}

cout << "Введенная матрица после изменения:" << endl; //вывод матрицы B

for (int i = 0; i < 3; i++)

{

 for (int j = 0; j < 4; j++)

 {

  cout.width(7);// выравниваем числа по7 позиций

  cout << a[i][j];

 }

 cout << endl;

}

system("pause");

return 0;

}

4,6(85 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ