Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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.*/
- #include <iostream>
- using namespace std;
- int main (void){
- const int valor=10;
- int vecnum[10];
- int i,valormax,posicionmax;
- cout<<"ingrese los valores: "<<endl;
- for (i=0 ; i<valor; i++){
- cout<<" Valor: "<<endl;
- cin>>vecnum[i];
- }
- for(i=0; i<valor; i++){
- if (i==0){
- valormax=vecnum[i];
- }
- else if(vecnum[i] >valormax)
- valormax=vecnum[i];
- posicionmax=i;
- }
- cout<<"mostrar valor max: "<<valormax<< endl;
- //vecnum[3]=vecnum[posicionmax];
- for(i=0; i<valor ; i++){
- if(vecnum[i]==valormax){
- vecnum[i]=vecnum[9];
- }
- }
- for(i=0; i<9;i++)
- {
- cout<<"los numeros sin "
- "el mayor son: "<<vecnum[i]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment