Răspuns:
a)#include <iostream>
using namespace std;
int main() {
int n, k, l;
cin >> n >> k;
l = n;
while (n != 0) {
l = n % 10;
if (l % k == 0)
cout << l << " ";
n /= 10;
}
}
b)
#include <iostream>
using namespace std;
int main() {
int n, l,cifmax=-1,cifmin=10;
cin >> n;
l = n;
while (n != 0) {
l = n % 10;
if (l > cifmax)
cifmax = l;
if (l < cifmin)
cifmin = l;
n /= 10;
}
cout << cifmax << " " << cifmin;
}
c)
#include <iostream>
using namespace std;
int main() {
int n, l,p=1;
cin >> n;
l = n;
while (n != 0) {
l = n % 10;
if (l % 2 == 1)
p = p * l;
n /= 10;
}
cout << p;
}
Explicație:
.