Advertisement
F_THIAGO

Lista I - Questão 6

Apr 19th, 2019
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. /*
  2. *   6] Ler 10 numeros e escrever o maior valor lido.
  3. */
  4.  
  5. #include <iostream>
  6.  
  7. // Dimensao do vetor
  8. #define DIM 10
  9.  
  10. using std::cout;
  11. using std::cin;
  12.  
  13. int main( void )
  14. {
  15.     float numeros[DIM];
  16.     float maior = 0;
  17.     int i;
  18.    
  19.     // ========== Entrada de Dados ============
  20.     for( i=0; i<DIM; i++ )
  21.     {
  22.         cout << "Elemento " << i+1 << ": ";
  23.         cin  >> numeros[i];
  24.        
  25.         // Verifica se o elemento digitado é maior que o suposto maior
  26.         if( i == 0 )
  27.             maior = numeros[i];
  28.         else if( numeros[i] > maior )
  29.             maior = numeros[i];
  30.     }
  31.    
  32.     // ========== Saida de dados =============
  33.     cout << "\nMaior elemento  " << maior;
  34.    
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement