Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void minmax(int a,int tab1[]);
  4. main()
  5. {
  6. int x,i;
  7. int tab[x];
  8. cout<<"Z ilu liczb sklada sie zbior: ";
  9. cin>>x;
  10. x=x-1;
  11. for(i=0;i<=x;i++)
  12. {
  13. cout<<"Podaj liczbe: ";
  14. cin>>tab[i];
  15. }
  16. minmax(x,tab);
  17. }
  18. void minmax(int a,int tab1[])
  19. {
  20. int i,min,max;
  21. for(i=0;i<=a;i++)
  22. {
  23. if(i==0)
  24. {
  25. min=tab1[i];
  26. max=tab1[i];
  27. }
  28. if(tab1[i]<min)
  29. {
  30. min=tab1[i];
  31. }
  32. else if(tab1[i]>min)
  33. {
  34. min=min;
  35. }
  36. if(tab1[i]<max)
  37. {
  38. max=max;
  39. }
  40. else if(tab1[i]>max)
  41. {
  42. max=tab1[i];
  43. }
  44.  
  45.  
  46. }
  47. cout<<"Najmnijsza liczba to: "<<min<<endl;
  48. cout<<"Najwieksza liczba to: "<<max;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement