Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // Parašykite programą, kuri padvigubinų duoto natūraliojo skaičiaus skaitmenis.
  2. // Pvz. : Jei n=1986, tai rezultatas turi būti 11998866.
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a;
  11. long long int b=0;
  12. long long int c=11;
  13. cout << "iveskite naturaluji skaiciu" << endl;
  14. cin >> a;
  15. if(a<0||!cin)
  16. {
  17. cout << "ivestas ne naturalusis skaicius" << endl;
  18. return 0;
  19. }
  20. while(a>0)
  21. {
  22. b=b+(a%10*c);
  23. a=(a-b/c)/10;
  24. c=c*100;
  25. }
  26. cout << b << endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement