Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /**
- * 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.
- Ejemplo:
- Vector → {1 3 9 1 4 6 2 0 5 7 }, quedará → {1 3 1 4 6 2 0 5 7}
- Nota: No mostrar el último elemento del vector.
- *
- */
- int main(){
- const int CANT = 10;
- int array[CANT], n_mayor=0, posicion_array;
- bool ordenado = 0;
- cout << "Ingrese 10 numeros distintos entre si: ";
- for(int i =0; i < CANT; i++){
- cin >> array[i];
- }
- for(int i=0; i < CANT;i++){
- if(array[i] > n_mayor){
- n_mayor = array[i];
- posicion_array=i;
- }
- }
- for(int i = posicion_array; i<CANT-1;i++){
- array[i]=array[i+1];
- }
- for(int i=0;i<CANT-1;i++){
- cout << array[i]<<", ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement