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

плз

Дана непустая последовательность положительных целых чисел а1 , а2 ,… оканчивающаяся нулем. Получить a1, a1*a2, a1*a2*a3, ..., 0
написать программу на с++

👇
Открыть все ответы
Ответ:
mashakuznetsova211
mashakuznetsova211
21.09.2020
Выводит 2 строки: Сам массив(20 элементов от 10 до 99) и строку с номерами элементов кратных 7, если таковых элементов нет, то пишет No elements.

program test;
uses crt;
const
  t:boolean=false;
var
  arr:array[1..20] of integer;
  i:integer;
begin
  randomize;
  clrscr;
  for i:=1 to 20 do
    begin
      arr[i]:=random(90)+10;
      write(arr[i],' ');
    end;
  writeln;
  for i:=1 to 20 do
    if arr[i] mod 7 = 0 then
      begin
        write(i,' ');
        t:=true;
      end;
  if t=false then
     write('No elements');
end.
4,8(89 оценок)
Ответ:
lollerkaa
lollerkaa
21.09.2020
Я здесь и для *(умножения тоже сделал)
program gt;
label 1;
var a:string;
i,l,s,s2,s3,j:longint;
begin
read(a);l:=length(a);s:=0;s2:=0;
for i:=1 to l do
begin
if (a[i]='+')or(a[i]='-')or(a[i]='*')then goto 1;
end;
1:
for j:=1 to i-1 do
begin
if a[j]='1' then s:=s*10+1;
if a[j]='2' then s:=s*10+2;
if a[j]='3' then s:=s*10+3;
if a[j]='4' then s:=s*10+4;
if a[j]='5' then s:=s*10+5;
if a[j]='6' then s:=s*10+6;
if a[j]='7' then s:=s*10+7;
if a[j]='8' then s:=s*10+8;
if a[j]='9' then s:=s*10+9;
if a[j]='0' then s:=s*10+0;
end;
for j:=i+1 to l do
begin
if a[j]='1' then s2:=s2*10+1;
if a[j]='2' then s2:=s2*10+2;
if a[j]='3' then s2:=s2*10+3;
if a[j]='4' then s2:=s2*10+4;
if a[j]='5' then s2:=s2*10+5;
if a[j]='6' then s2:=s2*10+6;
if a[j]='7' then s2:=s2*10+7;
if a[j]='8' then s2:=s2*10+8;
if a[j]='9' then s2:=s2*10+9;
if a[j]='0' then s2:=s2*10+0;
end;
if a[i]='+' then s3:=s+s2;
if a[i]='-' then s3:=s-s2;
if a[i]='*' then s3:=s*s2;
writeln(s3);
end.
2)более проще
program gt;
label 1;
var a:string;
i,l,s,s2,s3,j:longint;
begin
read(a);l:=length(a);s:=0;s2:=0;
for i:=1 to l do
begin
if (a[i]='+')or(a[i]='-')or(a[i]='*')then goto 1;
end;
1:
for j:=1 to i-1 do
begin
s:=s*10+ord(a[j])-48;
end;
for j:=i+1 to l do
begin
s2:=s2*10+ord(a[j])-48;
end;
if a[i]='+' then s3:=s+s2;
if a[i]='-' then s3:=s-s2;
if a[i]='*' then s3:=s*s2;
writeln(s3);
end.
4,4(69 оценок)
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ