Вопрос задан 17.02.2019 в 04:18. Предмет Информатика. Спрашивает Сарычев Иван.

Переведите с basic'e на pascal:CLSFOR a = 1 TO 100FOR b = 1 TO 100FOR c = 1 TO 100aa = a ^ 2bb = b

^ 2cc = c ^ 2IF aa + bb = cc AND aa < bb THEN z = z = 1NEXT cNEXT bNEXT aPRINT z
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Прилуцкий Артём.

Добавил ещё команду печати списка найденных троек, а не только их количества (строка   writeln('(',a,', ',b,', ',c,') '); ).


Program Vlad971997;
uses crt;
const n=100;
var
  a,b,c,count: integer;
begin
  writeln('*** alphaues is thinking... ***');
  writeln('***          OK             ***');
  count:=0;
  for a:=1 to n do
    for b:=1 to n do
      for c:=1 to n do
        if (a*a+b*b = c*c) and (a<b) then
          begin
            count:=count+1;
            writeln('(',a,', ',b,', ',c,') ');
          end;
  writeln('Всего найдено ',count,' пифагоровых троек');
end.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Translating the Basic code to Pascal

To translate the given Basic code to Pascal, you can use the following code:

```pascal program CLSFOR; var a, b, c, aa, bb, cc, z: integer; begin z := 0; for a := 1 to 100 do begin for b := 1 to 100 do begin for c := 1 to 100 do begin aa := a * a; bb := b * b; cc := c * c; if (aa + bb = cc) and (aa < bb) then z := z + 1; end; end; end; writeln(z); end. ```

This Pascal code is equivalent to the given Basic code. It initializes the variables `a`, `b`, `c`, `aa`, `bb`, `cc`, and `z` as integers. It then uses nested `for` loops to iterate through the values of `a`, `b`, and `c` from 1 to 100. Inside the loops, it calculates the squares of `a`, `b`, and `c` and assigns them to `aa`, `bb`, and `cc` respectively. It checks if the sum of `aa` and `bb` is equal to `cc` and if `aa` is less than `bb`. If both conditions are true, it increments the value of `z` by 1. Finally, it prints the value of `z`.

Please note that the provided code assumes that you have a Pascal compiler or IDE to run the code.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос