Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 6) Ler um vetor contendo 20 números, que correspondem a matrículas de alunos.
- Ler cinco números e imprimir uma mensagem informando se eles estão ou não presentes no vetor.
- */
- #include<iostream>
- #include<conio.h>
- using namespace std;
- int main()
- {
- int i, k, aluno[20], busca;
- for(i=0;i<20;i++)
- {
- cout << "Digite a matrícula do " << i+1 << "§ aluno: ";
- cin >> aluno[i];
- }
- for(k=0;k<5;k++)
- {
- cout << "Digite o " << k+1 << "§ codigo da matricula a pesquisar: ";
- cin >> busca;
- for(i=0;i<20;i++)
- {
- if(busca==aluno[i])
- {
- cout << "Matricula do aluno ESTA presente no vetor!" << endl;
- i=50;
- }
- }
- if(i==20){
- cout << "Matricula do aluno NAO ESTA presente no vetor!" << endl;
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement