Advertisement
add1ctus

Број на цифри

Sep 30th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int broj_na_cifri(int a)
  6. {
  7.     if(a==0)
  8.     return 1;
  9.     int broj=0;
  10.     while(a>0)
  11.     {
  12.         broj++;
  13.         a=a/10;
  14.     }
  15.     return broj;
  16. }
  17.  
  18. int main()
  19. {
  20.     int a;
  21.     cin>>a;
  22.     cout<<broj_na_cifri(a);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement