Advertisement
STANAANDREY

pb28

Nov 14th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     unsigned n,nrpar=0,nrimp=0,rang=0,nr;
  8.     cout<<"n=";cin>>n;
  9.    
  10.     while (n!=0)
  11.     {
  12.         rang++;
  13.         if (rang%2==0)
  14.             nrpar=nrpar*10+n%10;
  15.         else
  16.             nrimp=nrimp*10+n%10;
  17.         n/=10;
  18.     }
  19.  
  20.     int invnrimp=0,copynrpar=nrpar,p=1;
  21.     while (copynrpar!=0)
  22.     {
  23.        
  24.           p*=10;
  25.         copynrpar/=10;
  26.     }
  27.  
  28.  
  29.     while (nrimp!=0)
  30.     {
  31.         invnrimp=invnrimp*10+nrimp%10;
  32.         nrimp/=10;
  33.     }
  34.  
  35.  
  36.  
  37.    nr=invnrimp*p+nrpar;
  38.    cout<<"noul nr e: "<<nr;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement