0

#include

using namespace std;

int countDigit(int n) { int digits;

while (n != 0)
{
    n = n / 10;
    digits++;
}

return digits;

}

int main() { int number; cin >> number;

int cycles = countDigit(number);

int digitOfANumber[cycles];


for (int i = cycles - 1; i > 0; i--)
{
    digitOfANumber[i] = number % 10;
    number = number / 10;
}

cout << digitOfANumber[0];


return 0;

}

0

for (int i = cycles - 1; i >= 0; i--) { digitOfANumber[i] = number % 10; number = number / 10; }

1

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .