Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void Adicionar(int *vetor)
- {
- char opc;
- do
- {
- int indice,valor;
- cout << "\nInforme a posicao: ";
- cin >> indice;
- while( (indice < 0) || (indice > 10) )
- {
- cout << "Informe uma posicao valida!" << "\ndigite: ";
- cin >> indice;
- }
- cout << "Informe um valor para armazenar: ";
- cin >> valor;
- vetor[indice] = valor;
- cout << "Valor incluido com sucesso! ";
- cout << "Deseja inserir um novo valor? [S]im/[N]ao: ";
- cin >> opc;
- }while( (opc == 'S') || (opc == 's') );
- return;
- }
- void Remover(int *vetor)
- {
- int valor;
- cout << "Informe o valor a ser removido: ";
- cin >> valor;
- for(int i; i < 10 ; i++)
- {
- if(vetor[i] == valor)
- {
- cout << "Dado removido";
- break;
- }
- }
- return;
- }
- void Exibir(int *vetor)
- {
- for(int i = 0 ; i <= 10 ; i++)
- {
- cout << vetor[i] << '\t';
- }
- return;
- }
- void Zerar(int *vetor)
- {
- for( int i = 0 ; i < 10 ; i++)
- {
- vetor[i] = 0;
- }
- cout << "Limpeza de vetor concluida com sucesso\n";
- return;
- }
- int main()
- {
- int vetor[10],opc;
- Zerar(vetor);
- do
- {
- cout << "INFORME A OPCAO DESEJADA: \n"
- << "1- Inserir um valor desejado em uma posicao \n"
- << "2- Remover um valor de uma posicao desejada \n"
- << "3- Exibir os valores do vetor \n"
- << "4- Limpar todos os vetores \n" << "5- Sair ::";
- cin >> opc;
- switch(opc)
- {
- case 1 : Adicionar(vetor); break;
- case 2 : Remover(vetor); break;
- case 3 : Exibir(vetor); break;
- case 4 : Zerar(vetor); break;
- case 5 : return 0;
- default : cout << "Valor errado\n";
- }
- }while(true);
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement