Задача 1:
#include <iostream>
int main()
{
int n, s = 0;
setlocale(LC_ALL, "Russian"); // Русский язык в консоли
std::cout << "Введите число: ";
std::cin >> n;
while (n > 0)
{
if (n % 10 == 7) s++;
n /= 10;
}
std::cout << "Кол-во цифр 7 в числе: " << s;
return 0;
}
Задача 2:
#include <iostream>
int main()
{
int n, s = 0;
setlocale(LC_ALL, "Russian"); // Русский язык в консоли
std::cout << "Введите число: ";
std::cin >> n;
while (n > 0)
{
if (n % 10 == 3) s+=3;
n /= 10;
}
std::cout << "Сумма всех 3 в числе: " << s;
return 0;
}
Var
ar:array[1..10] of integer;
i:integer;
begin
for i:=1 to 10 do
begin
ar[i]:=i*3;
write(ar[i]:4);
end;
end.