Advertisement
Guest User

Zadanie 2

a guest
Jan 26th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. float xa,xb,xc,xd,xe;
  4.  
  5. float minimum(float a, float b, float c, float d, float e)
  6. {
  7.     float min=a;
  8.     for(int i=0; i<5; i++)
  9.     {
  10.         if(min>b) min=b;
  11.         else if(min>c) min=c;
  12.         else if(min>d) min=d;
  13.         else if(min>e) min=e;
  14.     }
  15.    
  16.     return min;
  17. }
  18.  
  19. float maksimum(float a, float b, float c, float d, float e)
  20. {
  21.     float max=a;
  22.    
  23.     for(int i=0; i<5; i++)
  24.     {
  25.         if(max<b) max=b;
  26.         else if(max<c) max=c;
  27.         else if(max<d) max=d;
  28.         else if(max<e) max=e;
  29.     }
  30.  
  31.     return max;
  32. }
  33.  
  34. int main()
  35. {
  36.     printf("Podaj wartosc liczy a: ");
  37.     scanf("%f", &xa);
  38.     printf("Podaj wartosc liczy b: ");
  39.     scanf("%f", &xb);
  40.     printf("Podaj wartosc liczy c: ");
  41.     scanf("%f", &xc);
  42.     printf("Podaj wartosc liczy d: ");
  43.     scanf("%f", &xd);
  44.     printf("Podaj wartosc liczy e: ");
  45.     scanf("%f", &xe);
  46.    
  47.     printf("\nNajmniejsza liczba to: %.2f\n", minimum(xa,xb,xc,xd,xe) );
  48.     printf("Najwieszka liczba to: %.2f\n", maksimum(xa,xb,xc,xd,xe) );
  49.    
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement