Возможный вариант в C++ #include <iostream> int main() { using namespace std; int N; cout << "Enter N: "; cin >> N; int num; int max = 1; int i; for (i = 0; i < N; ++i) { cout << "Enter #" << i + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) { max = num; break; } } for (int j = i + 1; j < N; ++j) { cout << "Enter #" << j + 1 << " number: "; cin >> num; if ((num - 9) % 10 != 0 && num % 3 == 0) if (num > max) max = num; } if (max != 1) cout << "Max number div by 3 and don't end 9: " << max << endl; else cout << "No numbers div by 3 and don't end 9" << endl; return 0; }
//1 var A, B, i: integer; begin write('Введите A и B: '); readln(A, B); for i := A to B do if ((i mod 3 = 0) and (i mod 10 = 3)) then writeln(i); end.
//2 var A, B, i, k: integer; begin write('Введите A и B: '); readln(A, B); for i := A to B do if ((i > 99) and (i < 1000)) and ((i mod 10 = 9) and (i mod 100 <> 99)) then begin writeln(i); k := k + 1; end; if k = 0 then writeln('Таких чисел нет.'); end.
//3 var sum, i, n: integer; begin write('Введите количество предметов: '); readln(n); for i := 1 to n do begin readln(n); sum := sum + n; end; writeln('Общая масса = ', sum); end.
//3 с другим циклом var sum, n: integer; begin writeln('Введите 0 для завершения ввода.'); repeat readln(n); sum := sum + n; until n = 0; writeln('Общая масса = ', sum); end.
#include <iostream>
int main()
{
using namespace std;
int N;
cout << "Enter N: ";
cin >> N;
int num;
int max = 1;
int i;
for (i = 0; i < N; ++i)
{
cout << "Enter #" << i + 1 << " number: ";
cin >> num;
if ((num - 9) % 10 != 0 && num % 3 == 0)
{
max = num;
break;
}
}
for (int j = i + 1; j < N; ++j)
{
cout << "Enter #" << j + 1 << " number: ";
cin >> num;
if ((num - 9) % 10 != 0 && num % 3 == 0)
if (num > max)
max = num;
}
if (max != 1)
cout << "Max number div by 3 and don't end 9: " << max << endl;
else
cout << "No numbers div by 3 and don't end 9" << endl;
return 0;
}
var A, B, i: integer;
begin
write('Введите A и B: '); readln(A, B);
for i := A to B do
if ((i mod 3 = 0) and (i mod 10 = 3)) then writeln(i);
end.
//2
var
A, B, i, k: integer;
begin
write('Введите A и B: '); readln(A, B);
for i := A to B do
if ((i > 99) and (i < 1000)) and ((i mod 10 = 9) and (i mod 100 <> 99)) then
begin
writeln(i);
k := k + 1;
end;
if k = 0 then writeln('Таких чисел нет.');
end.
//3
var sum, i, n: integer;
begin
write('Введите количество предметов: '); readln(n);
for i := 1 to n do
begin
readln(n);
sum := sum + n;
end;
writeln('Общая масса = ', sum);
end.
//3 с другим циклом
var sum, n: integer;
begin
writeln('Введите 0 для завершения ввода.');
repeat
readln(n);
sum := sum + n;
until n = 0;
writeln('Общая масса = ', sum);
end.