Professional Documents
Culture Documents
HOMOGNEAS
VETORES
Disciplina: Estrutura de Dados
Professora: Mirlem R. Ribeiro
Email: mirlem@ifam.edu.br
VETORES
Em Linguagem C:
tipo+ identificador+ [nmero de variveis];
Onde:
tipo: o tipo das variveis que devem ser criadas.
Ex.: int, char, float, entre outros;
identificador: o nome que ser utilizado para referenciar o
conjunto de variveis;
nmero de variveis: o nmero de variveis que ser criado
(tamanho do vetor).
VETORES
Declarao em C
Tipo nome
nome[[tamanho
tamanho];
]; // ndices de 0 at tamanho nn-1
Tipo nome
nome[]
[] = {Elemento1,E2,...,En
{Elemento1,E2,...,En};
}; // tamanho = n
Tipo nome
nome[[tamanho
tamanho]] = {E1,E2,...,En
{E1,E2,...,En};
}; // n <= tamanho
0
VET
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
0
VET
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
VET
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
VET
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
VET
-3
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
0
VET
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
0
VET
i
1
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
0
VET
5
i
1
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
0
VET
5
i
1
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
0
VET
5
i
2
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
2
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
2
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
3
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
3
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
3
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
i
4
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
VET
-3
i
4
VETORES
Manipulao em C
Entrada de Dados
Vet[0]=5;
Vet[1]=8;
Vet[2]=1;
Vet[3]=-3;
SADA
For (i=0; i<4; i++)
printf(%d,Vet[i]);
i
Ou
For (i=0; i<4; i++)
scanf(%d,&Vet[i]);
For a do Limite Superior
VET
-3
#include <iostream>
#include <conio.h>
using namespace std;
int main (){
int vet[5];
int i;
//ENTRADA
cout << "Preencha o vetor \n ";
for (i = 0; i < 5; i++){
cin >> vet[i];
}
//SADA
cout << "Preencha o vetor ";
for (i = 0; i < 5; i++){
cout << vet[i];
}
getch();
return 0;
}
OBSERVAES
EXERCCIOS
1.
a)
b)
c)
d)
e)
f)
g)
h)
i)
10
21
33
14
EXERCCIOS
2.
3.
4.
5.
6.
7.
EXERCCIOS
8) Elabore um programa que, dados dois vetores inteiros de 10
posies, efetue as respectivas operaes indicadas por
outro vetor de 10 posies de caracteres tambm fornecido
pelo usurio, contendo as quatros operaes aritmticas em
qualquer combinao e armazenando os resultados em um
quarto vetor.