Advertisement
STANAANDREY

pb30

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