Răspuns:
#include <iostream>
using namespace std;
int main()
{
int a, n=0, i, v[100];
cin >> a;
while (a) {
v[n++]=a;
cin >> a;
}
int m, f=0, s;
for (i=2; i<n; i++) {
m=v[i-2];
s=0;
while (m) {
s+=m%10;
m/=10;
}
if (v[i-2]/s==v[i-1] && v[i-2]%s==v[i]) {
cout << v[i-2] << " " << v[i-1] << " " << v[i] << endl;
f=1;
}
}
if (f==0) cout << "nu exista";
return 0;
}
Explicație: