Evo celog programa:
Code:
#include <iostream>
using namespace std;
int brojCifara(int broj)
{
int brCifara = 0;
while(broj)
{
broj /= 10;
brCifara++;
}
return brCifara;
}
int proizvodCifara(int broj)
{
int proizvod = 1;
while(broj)
{
int cifra = broj%10;
proizvod*=cifra;
broj/=10;
}
return proizvod;
}
void main()
{
int broj = 27;
int tempBroj = broj; // da ne bi menjali broj
while(brojCifara(tempBroj) != 1)
{
tempBroj = proizvodCifara(tempBroj);
}
cout << "Rezultat za broj: " << broj << " je " << tempBroj << endl;
}
EOF