Advertisement
Guest User

HelpSolution

a guest
May 6th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. /*
  2. 6) Ler um vetor contendo 20 números, que correspondem a matrículas de alunos.
  3. Ler cinco números e imprimir uma mensagem informando se eles estão ou não presentes no vetor.
  4. */
  5.  
  6. #include<iostream>
  7. #include<conio.h>
  8. using namespace std;
  9. int main()
  10. {
  11.     int i, k, aluno[20], busca;
  12.    
  13.     for(i=0;i<20;i++)
  14.     {
  15.         cout << "Digite a matrícula do " << i+1 << "§ aluno: ";
  16.         cin >> aluno[i];
  17.     }
  18.    
  19.     for(k=0;k<5;k++)
  20.     {
  21.         cout << "Digite o " << k+1 << "§ codigo da matricula a pesquisar: ";
  22.         cin >> busca;
  23.        
  24.         for(i=0;i<20;i++)
  25.         {
  26.             if(busca==aluno[i])
  27.             {
  28.                 cout << "Matricula do aluno ESTA presente no vetor!" << endl;
  29.                 i=50;
  30.             }
  31.         }
  32.         if(i==20){
  33.             cout << "Matricula do aluno NAO ESTA presente no vetor!" << endl;
  34.         }
  35.     }
  36.     getch();
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement