4.cpp 593 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. const int n = 5;
  5. int array[n];
  6. int max, min;
  7. cout << "Input array's elements: " << endl;
  8. for (int i = 0; i < n; i++){
  9. cin >> array[i];
  10. }
  11. cout << "----------" << endl;
  12. max = min = array[0];
  13. for (int i = 0; i < n; i++){
  14. if (max < array[i]){
  15. max = array[i];
  16. }
  17. if (min > array[i]){
  18. min = array[i];
  19. }
  20. }
  21. for (int i = 0; i < n; i++){
  22. if (array[i] == max){
  23. array[i] = +1;
  24. }
  25. else if (array[i] == min){
  26. array[i] = -1;
  27. }
  28. }
  29. for (int i = 0; i < n; i++){
  30. cout << array[i] << endl;
  31. }
  32. return 0;
  33. }