bogdanNiculeasa

Parcurgere numar de la stanga la dreapta

Dec 9th, 2023
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n = 56789;
  8.     int p = 1;
  9.     while (p * 10 <= n) {
  10.         p = p * 10;
  11.     }
  12.  
  13.     while (n > 0) {
  14.         int primaCifra = n / p;
  15.         cout << primaCifra <<" ";
  16.         n = n % p;
  17.         p = p/10;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment