daverkieva568
?>

Write a line of code that prints the integer portion of the number 21.45 2. Write a line of code that prints a random number between 1 and 6 3. Assume that a user enters any number and that the number is stored in the variable userNumber. Write a line of code that converts the input to a float. Then write a line of code that prints the positive value of the user’s input. 4. Write a line of code that calculates the square root of 900 and stores the result in the variable answer. 5. Revisit the programs you have written in the past. Write down all of the predefined routines you have used and for each one identify if it is a function or a procedure.

Информатика

Ответы

BirUlek215
У меня получилось вот что (смотри скриншоты листинга программы и результата работы этой программы):
uses Crt;
const n = 10;
var A: array [1..n] of integer; 
        i: integer;
begin 
ClrScr; 
Randomize; 
WriteLn ( ' Massiv I: '); 
for i:=1 to n do 
    begin     
          A[i] := 1+random(n);  
          Write (A[i]:4); 
    end; 
WriteLn; WriteLn ( ' Massiv II: '); 
for i:=1 to n do 
    begin   
           if (A[i] mod 2 =0) then A[i]:=0 else A[i]:=3*A[i];     
           Write (A[i]:4); 
   end;
ReadLn;
end.     
Составьте программу, которая запол няет массив a [1..10] случайными целыми числа ми в диапазоне от 1
Составьте программу, которая запол няет массив a [1..10] случайными целыми числа ми в диапазоне от 1
Galliardt Sergeevna1284
Program q1;
uses crt;
const n=10;
var i,j:integer;
mass:array [1..n] of integer;
countNum:integer; // переменная для хранения количества нечетных чисел
proizv:integer; // переменная для хранения произведения нечетных чисел
BEGIN
proizv:=1; // так как, изначально равно 0, а при умножении на 0 будет всегда 0
{создание последовательности n целых чисел}
Writeln('Случайные целые числа: ');
for i:=1 to n do
begin
mass[ i ]:=random(9)+1; //присваеваем переменной случайное значение от 1 до 10
write(inttostr(mass[ i ])+', ');
end;
{Вычисление произведения и количества нечетных чисел}
for i:=1 to n do
if mass[ i ] mod 2 <> 0 then //проверяем не четное-ли число, если да, то.. .
begin
inc(countNum); //увеличиваем на один кол-во нечетных чисел
proizv:=proizv*mass[ i ]; // высчитываем произведение
end;
{Вывод результатов}
writeln;
writeln('Всего нечетных чисел: '+inttostr(countNum));
writeln('Их произведение: '+inttostr(proizv));
END.

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Write a line of code that prints the integer portion of the number 21.45 2. Write a line of code that prints a random number between 1 and 6 3. Assume that a user enters any number and that the number is stored in the variable userNumber. Write a line of code that converts the input to a float. Then write a line of code that prints the positive value of the user’s input. 4. Write a line of code that calculates the square root of 900 and stores the result in the variable answer. 5. Revisit the programs you have written in the past. Write down all of the predefined routines you have used and for each one identify if it is a function or a procedure.
Ваше имя (никнейм)*
Email*
Комментарий*