Advertisement
sellmmaahh

tut4-zad2

Jul 21st, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4.  
  5.  
  6. void Cifre (int n, int &c_max, int &c_min) {
  7.    int x(n), y(n);
  8.     c_max=x%10;
  9.     x/=10;
  10.     while  (x!=0)
  11.         { if ((x%10)>c_max) c_max=x%10;
  12.         x/=10; }
  13.  
  14.    c_min=y%10;
  15.    y/=10;
  16.    while (y!=0)
  17.    {
  18.        if ((y%10)<c_min) c_min=y%10;
  19.        y/=10;
  20.    }
  21.  }
  22.  int main ()
  23.  {
  24.      int a,b;
  25.      Cifre(37232645, a, b);
  26.      std::cout<<"Najveca cifra: "<<a<<std::endl;
  27.      std::cout<<"Najmanja cifra: "<<b;
  28.      return 0;
  29.  
  30.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement