Решение на паскале.
Объяснение:
Первая задача:
var summa, kolichestvo : integer;
begin
summa := 2;
while summa <= 100 do
summa := summa + 8;
kolichestvo := kolichestvo + 1;
end;
writeln('Количество = ', kolichestvo);
end.
Вторая задача:
var a : array[1..20] of integer;
kolpol, sumot, i : integer;
for i:=1 to 20 do
Read(a[i]);
for i := 1 to 20 do
if a[i] >= 0 then
kolpol := kolpol +1
else
sumot := sumot + a[i];
writeln('Количество положительных = ', kolpol);
writeln('Сумма отрицательных = ', sumot);
#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
int i = 100, count = 0;
while (i <= 999) {
string temp = to_string(i);
if ((temp[0] - '0') * (temp[1] - '0') * (temp[2] - '0') == N) {
cout << i << ", " << temp[0] << " * " << temp[1] << " * " << temp[2] << " = " << N << endl;
++count;
}
++i;
cout << "Total: " << count;
Решение на паскале.
Объяснение:
Первая задача:
var summa, kolichestvo : integer;
begin
summa := 2;
while summa <= 100 do
begin
summa := summa + 8;
kolichestvo := kolichestvo + 1;
end;
writeln('Количество = ', kolichestvo);
end.
Вторая задача:
var a : array[1..20] of integer;
kolpol, sumot, i : integer;
begin
for i:=1 to 20 do
Read(a[i]);
for i := 1 to 20 do
if a[i] >= 0 then
kolpol := kolpol +1
else
sumot := sumot + a[i];
writeln('Количество положительных = ', kolpol);
writeln('Сумма отрицательных = ', sumot);
end.
#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
int i = 100, count = 0;
while (i <= 999) {
string temp = to_string(i);
if ((temp[0] - '0') * (temp[1] - '0') * (temp[2] - '0') == N) {
cout << i << ", " << temp[0] << " * " << temp[1] << " * " << temp[2] << " = " << N << endl;
++count;
}
++i;
}
cout << "Total: " << count;
}