Advertisement
amermo

TP T-4 Z2

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