М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
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.​

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

var

 s, s1, s2, s3, s4, tmp1, tmp2: string;

 i, a, b, c, d, e, f: integer;

begin

 Writeln('Введите строку: ');

 Readln(s);

 //

 for var k := 1 to length(s) do  

 begin

   if (s[k] = '(') then

   begin

     var j := k + 1;

     while (s[j].IsDigit) do

     begin

       tmp1 := tmp1 + s[j];

       j := j + 1;

     end;

     var ch := s[j];

     j := j + 1;

     while (s[j].IsDigit) do

     begin

       tmp2 := tmp2 + s[j];

       j := j + 1;

     end;

     case ch of

       '+': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger + tmp2.ToInteger)); end;

       '-': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger - tmp2.ToInteger)); end;

       '*': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger * tmp2.ToInteger)); end;

       '/': begin s := s.Remove(k - 1, j - k + 1); s := s.Insert(k - 1, inttostr(tmp1.ToInteger div tmp2.ToInteger)); end;

     end;

     break;

   end;

 end;

 //

 for i := 1 to length(s) do

 begin

   if (s[i] = '+') or (s[i] = '-') or (s[i] = '*') or (s[i] = '/') then

   begin

     s1 := copy(s, 1, i - 1);

     s2 := copy(s, i + 1, length(s));

     c := i;

   end;

 end;

 for i := 1 to length(s1) do

 begin

   if (s1[i] = '+') or (s1[i] = '-') or (s1[i] = '*') or (s1[i] = '/') then

   begin

     s3 := copy(s1, 1, i - 1);

     s4 := copy(s1, i + 1, length(s1));

     e := i;

   end;

 end;

 Val(s3, a, d);

 Val(s4, b, d);

 Val(s2, f, d);

 if (s[e] = '/') and (s[c] = '/') then Writeln((a div b) div f);

 if (s[e] = '/') and (s[c] = '*') then Writeln((a div b) * f);

 if (s[e] = '+') and (s[c] = '*') then Writeln(a + (b * f));

 if (s[e] = '*') and (s[c] = '*') then Writeln(a * b * f);

 if (s[e] = '+') and (s[c] = '/') then Writeln(a + (b div f));

 if (s[e] = '*') and (s[c] = '+') then Writeln((a * b) + f);

 if (s[e] = '/') and (s[c] = '+') then Writeln((a div b) + f);

 if (s[e] = '*') and (s[c] = '/') then Writeln((a * b) div f);

 if (s[e] = '+') and (s[c] = '+') then Writeln(a + b + f);

 if (s[e] = '-') and (s[c] = '-') then Writeln(a - b - f);

 if (s[e] = '+') and (s[c] = '-') then Writeln(a + b - f);

 if (s[e] = '-') and (s[c] = '+') then Writeln(a - b + f);

 if (s[e] = '*') and (s[c] = '-') then Writeln((a * b) - f);

 if (s[e] = '/') and (s[c] = '-') then Writeln((a div b) - f);

 if (s[e] = '-') and (s[c] = '*') then Writeln(a - (b * f));

 if (s[e] = '-') and (s[c] = '/') then Writeln(a - (b div f));

end.

4,6(73 оценок)
Ответ:
milarudneva449
milarudneva449
29.04.2021
Язык C++.
1. #include <iostream>
using namespace std;
int main() {
    int i;
    cout <<"Введите число: " << endl;
    cin >> i;
    cout << "Вы ввели число: " << i << endl;
    }

2. #include <iostream>
using namespace std;
int main (){
    int i;
    cout << "Vvod" << endl;
    cin >> i;
    i %= 10;
    if(i %2 != 0)
    cout << "Нечетная" << endl;
    else
    cout << "Четная" << endl;
    }

3. #include<iostream>
using namespace std;
int main (){
for(int k = 0; k<4; k++){
cout << "random number = " << rand() << endl;
}
}

4. #include <iostream>
using namespace std;
int main(){
int i,a,b,c;
cin >> i;
c = i%10;
b =(i/10)%10;
a = i/100;
if(i*i==a*a*a+b*b*b+c*c*c)
cout<<"Является."<<endl;
else 
cout<<"Не является."<<endl;
}

5. #include <iostream>
#include <cmath>
const double pi = 3.1415926536;
using namespace std;
int main(){
    float x = 0;    cout << "Введите x: " << endl;
    cin >> x;
    cout << "y = " <<  sin((pi*(3.2+(sqrt(1+x))))/180)/abs(5*x) << endl;
    }

Добавляем "pi" и делим на 180, чтобы "sin" был в градусах.

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