Răspuns :
#include <iostream>
using namespace std;
int main()
{
int n,cifra,ok=0;
long long int prod=1;
//Introduce un nr. de la tastatura:
cin>>n;
while (n!=0)
{
cifra=n%10;
if(cifra%2!=0)
{
prod=prod*cifra;
ok=1;
}
n=n/10;
}
if(ok==0)
{
cout<<-1;
}
else
{
cout <<prod;
}
return 0;
}
Sper sa te ajute ! Succes!
using namespace std;
int main()
{
int n,cifra,ok=0;
long long int prod=1;
//Introduce un nr. de la tastatura:
cin>>n;
while (n!=0)
{
cifra=n%10;
if(cifra%2!=0)
{
prod=prod*cifra;
ok=1;
}
n=n/10;
}
if(ok==0)
{
cout<<-1;
}
else
{
cout <<prod;
}
return 0;
}
Sper sa te ajute ! Succes!
#include<iostream>
using namespace std;
int main()
{ int n,p=1,c;
cout<<"n= "; cin>>n;
while(n>0)
{ c=n%10;
n=n/10;
if(c%2==1)
p*=c;
} cout<<p<<endl; return 0;}
using namespace std;
int main()
{ int n,p=1,c;
cout<<"n= "; cin>>n;
while(n>0)
{ c=n%10;
n=n/10;
if(c%2==1)
p*=c;
} cout<<p<<endl; return 0;}