ksa010402
06.04.2021 15:52

Вычислить произведение второго отрицательного и пятого элементов.
Напишите программу в Python, и блок схему тоже

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
hiordi
28.08.2021 09:58
Код#include <iostream>constexpr double bites_to_megabytes(double a) {    return a / 8388608;}constexpr double megabytes_to_gigabytes(double a) {    return a / 1024;}int main() {    long long a;    short type;    bool is_correct = false;    double answer;    do {        std::cin >> a;        std::cout << "[1] Megabytes \n"                  << "[2] Gigabytes \n"                  << "Convert to [1] or [2]: ";        std::cin >> type;        if (type == 1 or type == 2) {            is_correct = true;        } else {            std::cout << "Meh. Try to type again. \n" << std:: endl;        }    } while (!is_correct);    switch (type) {        case 1:            answer = bites_to_megabytes(a);            break;        case 2:            answer = megabytes_to_gigabytes(bites_to_megabytes(a));            break;    }    std::cout << "An answer of conversion is " << answer << std::endl;    return 0;}
0,0(0 оценок)
Ответ:
даша5501
09.02.2023 10:16
// PascalABC.NET 3.1, сборка 1179 от 29.02.2016
procedure GetProdNeg(a:array of integer; var p:real);
// произведение отрицательных элементов
begin
  p:=a.Where(x->x<0).Aggregate(1.0,(p,e)->p*e)
end;

function IsPrime(n:integer):boolean:=
  Range(2,Round(sqrt(n))).All(i->n mod i<>0);

procedure ArrPrime(n:integer; var a:array of integer);
// массив простых чисел не больших n
begin
  a:=Range(2,n).Where(i->IsPrime(i)).ToArray
end;

begin
  var n:=ReadInteger('n=');
  var a:=ArrRandom(n,-50,50); a.Println;
  var r:real;
  GetProdNeg(a,r);
  Writeln('Произведение ',r);
  n:=ReadInteger('n=');
  var b:array of integer;
  ArrPrime(n,b);
  b.Println
end.

Тестовое решение:
n= 15
27 -7 -36 40 -15 -21 -47 -28 -12 45 3 -38 -15 1 -39
Произведение 27866837980800
n= 300
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота