Advertisement
escuderopablo

TP6 _ Ejercicio 6

May 22nd, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | Software | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. /**
  5.  * Se ingresa por teclado un vector de 10 elementos todos distintos entre sí. Luego eliminar el valor máximo y desplazar todos los elementos un lugar.
  6. Ejemplo:     
  7. Vector → {1 3 9 1 4 6 2 0 5 7 }, quedará → {1 3 1 4 6 2 0 5 7}
  8. Nota: No mostrar el último elemento del vector.
  9.  *
  10. */
  11.  
  12. int main(){
  13.     const int CANT = 10;
  14.     int array[CANT], n_mayor=0, posicion_array;
  15.     bool ordenado = 0;
  16.     cout << "Ingrese 10 numeros distintos entre si: ";
  17.     for(int i =0; i < CANT; i++){
  18.         cin >> array[i];
  19.     }
  20.  
  21.     for(int i=0; i < CANT;i++){
  22.         if(array[i] > n_mayor){
  23.             n_mayor = array[i];
  24.             posicion_array=i;
  25.         }
  26.     }
  27.  
  28.     for(int i = posicion_array; i<CANT-1;i++){
  29.         array[i]=array[i+1];
  30.     }
  31.  
  32.     for(int i=0;i<CANT-1;i++){
  33.         cout << array[i]<<", ";
  34.     }
  35.    
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement