Advertisement
DaniDori

Цифры числа в столбик

Jan 22nd, 2023
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13. void vvod(int n,int k)
  14. {
  15.     while (k>0){
  16.         cout << n/k<<endl;
  17.         n=n%k;
  18.         k/=10;
  19.        
  20.     }
  21. }
  22. void colichestvo (int n){
  23.     int k=1,  g=n;
  24.     while (n/10>0){
  25.         k*=10;
  26.         n/=10;
  27.     }
  28.     vvod(g,k);
  29.    
  30. }
  31. int main()
  32. {
  33.     int n;
  34.     cin >> n;
  35.     colichestvo(n);
  36.    
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement