Advertisement
dinky_moop

My code

Jun 16th, 2022
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. void digit (int num)
  5. {
  6.     int num2 = num;
  7.     int dc = 0;
  8.     int x =0;
  9.     int divisor = 0;
  10.    
  11.     {
  12.             num=num/10;
  13.             dc++;
  14.     }
  15.     divisor = pow(10, dc);
  16.    
  17.    
  18.     while(dc < num)
  19.     {
  20.      num=num/10;
  21.      dc++;
  22.     }
  23.  
  24.        divisor = pow(10, dc);
  25.        
  26.        while(divisor > 0)
  27.        {
  28.            
  29.            x = num2/divisor;
  30.            
  31.            cout << x << endl;
  32.            
  33.            x=x*divisor;
  34.            
  35.            x=num2-x;
  36.            
  37.            divisor=divisor/10;
  38.          
  39.        }
  40. }
  41. int main ()
  42. {
  43.     int num = 0;
  44.     cout << "Please enter a number: ";
  45.     cin >> num;
  46.    
  47.     digit(num);
  48.    
  49.     cin.ignore();
  50.     cin.get();
  51.     return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement