Advertisement
sellmmaahh

zsr2-6. Izbaci nule

Mar 12th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iomanip>
  4.  
  5.  
  6.  
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. int izbacinule(int n)
  12. {
  13.     int broj=n, nb(0),k(1), cifra;
  14.     while (broj!=0)
  15.     {
  16.         cifra=broj%10;
  17.         while (broj%10==0)
  18.         broj/=10;
  19.         cifra=broj%10;
  20.         nb=cifra*k+nb;
  21.         broj/=10;
  22.         k*=10;
  23.     }
  24.     return nb;
  25. }
  26.  
  27. int main()
  28. {
  29.     int n;
  30.     std::cout<<"Unesite prirodan broj: "<<std::endl;
  31.     cin>>n;
  32.     std::cout<<"Novi broj: "<<std::endl;
  33.     int a=izbacinule(n);
  34.     cout<<a;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement