for (int i = 0; i < 4; i++) { int iEnd = iNumber % 10; if (iEnd % 2 == 0) iMulEven *= iEnd, cMask |= 1; else iMulOdd *= iEnd, cMask |= 2; iNumber /= 10; }
if (cMask == 3) std::cout << static_cast<double>(iMulEven) / iMulOdd << std::endl; else if (cMask == 1) std::cout << "There is no odd digits exists." << iMulEven << std::endl; else std::cout << "There is no even digits exists." << iMulOdd << std::endl; return 0; } /* end of the 'main' function */
/* main program function */
int main()
{
int
iMulEven = 1,
iMulOdd = 1,
iNumber;
char cMask = 0;
std::cin >> iNumber;
if (iNumber > 9999 || iNumber < 1000)
{
std::cout << "Error! Input the correct number!" << std::endl;
return 0;
}
for (int i = 0; i < 4; i++)
{
int iEnd = iNumber % 10;
if (iEnd % 2 == 0)
iMulEven *= iEnd, cMask |= 1;
else
iMulOdd *= iEnd, cMask |= 2;
iNumber /= 10;
}
if (cMask == 3)
std::cout << static_cast<double>(iMulEven) / iMulOdd << std::endl;
else if (cMask == 1)
std::cout << "There is no odd digits exists." << iMulEven << std::endl;
else
std::cout << "There is no even digits exists." << iMulOdd << std::endl;
return 0;
} /* end of the 'main' function */