Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int Cifre (long long int n, int &c_min = 0, int &c_max = 0){
  5.  
  6. int brojCifara = 0;
  7. if(n<0) n=abs(n);
  8.  
  9. while(n!=0){
  10.  
  11. int pomocna = n%10;
  12. n = n/10;
  13.  
  14. if(pomocna > c_max){
  15. c_max = pomocna;
  16. }
  17. else if(pomocna < c_min){
  18. c_min = pomocna;
  19. }
  20. brojCifara++;
  21. }
  22. return brojCifara;
  23.  
  24. }
  25.  
  26. int main ()
  27. {
  28. long long int broj;
  29. int a, b;
  30. std::cout << "Unesite broj: ";
  31. std::cin >> broj;
  32.  
  33. int e = Cifre(broj, a, b);
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement