tungggg

de quy dau vs de quy duoi

Apr 8th, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. #define ll long long
  9.  
  10. void printFromLeft (ll n){
  11.     if ( n==0 ) return ;
  12.     printFromLeft(n/10);
  13.     int r=n%10;
  14.     cout<<r<<" ";
  15. }
  16.  
  17. void printFromRight(ll n){
  18.     if ( n==0 ) return ;
  19.     int r= n%10;
  20.     cout<<r<<" ";
  21.     printFromRight(n/10);
  22. }
  23.  
  24. int main() {
  25.     ll n;
  26.     cin >> n;
  27.     printFromLeft(n);
  28.     cout<<endl;
  29.     printFromRight(n);
  30.    
  31.     /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment