Advertisement
Guest User

Untitled

a guest
Jan 14th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8. int x, y, z;
  9. int arr[] = { 1,7,4 };
  10. int max = arr[0];
  11. int min = arr[0];
  12. int average;
  13. for (int i = 1; i < 3; i++)
  14. {
  15. if (arr[i] > max)
  16. {
  17. max = arr[i];
  18. }
  19. }
  20. cout << max;
  21.  
  22. for (int i = 1; i < 3; i++)
  23. {
  24. if (arr[i] < min)
  25. {
  26. min = arr[i];
  27. }
  28. }
  29. cout << "\n" << min;
  30.  
  31. for (int i = 1; i < 3; i++)
  32. {
  33. if ((arr[i] > min) && (arr[i] < max))
  34. {
  35. average = arr[i];
  36. }
  37. }
  38.  
  39. x = max;
  40. z = min;
  41. y = average;
  42.  
  43. cout << "\n" << x << " is x, " << z << " is z, " << y << " is y";
  44.  
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement