Advertisement
sellmmaahh

razlika min i max cifri

Feb 5th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int raz (int n)
  5. {
  6.     int cifra, nb=0, min=9, max=0;
  7.     while (n!=0)
  8.       { cifra =n%10;
  9.         if (cifra>max)
  10.             max=cifra;
  11.         if (cifra<min)
  12.             min=cifra;
  13.             n/=10;
  14.  
  15. } return max-min;
  16. }
  17. int main ()
  18. {
  19.     int broj;
  20.     printf("unesite broj: ");
  21.     scanf("%d", &broj);
  22.     printf("Razlika najvece i najmanje: %d ", raz(broj) );
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement