Documente Academic
Documente Profesional
Documente Cultură
-> poate fi de tipul: int, char, char*, long, float, void, etc.
-> in cazul in care tipul returnat nu este specificat acesta este implicit int
#include <iostream>
using namespace std;
int n;
int cifreImpare(int n)
{
int s = 0, cn = n, p = 1;
while (n > 0)
{
if (n % 2 == 0)
{
s = n % 10 * p + s;
p = p * 10;
}
n = n / 10;
}
if (s == 0 || s == cn)
return -1;
return s;
}
int main()
{
cin >> n;
cout << cifreImpare(n);
return 0;
}