87

1. Заменить все положительные элементы массива на 99,2. Составить программу, вычисл.…

06 сентября 2022

1. Заменить все положительные элементы массива на 99,2. Составить программу, вычисл. Произведения положительных и сумму отрицательных элементов.

категория: информатика



76

Pascal: 1) const n=10; var a: array [1… n] of integer; i: integer; begin randomize; for i: =1 to n do begin a[i]: =random (21) -10; write (a[i]: 3); end; writeln; for i: =1 to n do begin if a[i]>0 then a[i]: =99; write (a[i]: 3); end; writeln; end.2) const n=10; var a: array [1… n] of integer; p,s,i: longint; begin p: =1; s: =0; randomize; for i: =1 to n do begin a[i]: =random (21) -10; if a[i]>0 then p: =p*a[i] else if a[i]<0 then s: =s+a[i]; write (a[i]: 3); end; writeln; writeln ('Proizvedenie: ',p); writeln ('Summa: ',s); end.C+: 1) #include #include #include using namespace std; int main () { int a[10]; srand (time (NULL); for (int i=0; i<10; i+) { a[i]=rand () %20-10; cout <0) a[i]=99; } cout <#include #include using namespace std; int main () { int a[10]; int p=1,s=0; srand (time (NULL); for (int i=0; i<10; i+) { a[i]=rand () %20-10; cout <0) p*=a[i]; else if (a[i]<0) s+=a[i]; } cout <

Знаете ответ?


Есть интересный вопрос? Задайте его нашему сообществу, у нас наверняка найдется ответ!
Делитесь опытом и знаниями, зарабатывайте награды и репутацию, заводите новых интересных друзей!
Задавайте интересные вопросы, давайте качественные ответы и зарабатывайте деньги. Подробнее...