fellipeh

Untitled

Oct 5th, 2020
1,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int qtde;
  8.     int *notas;
  9.    
  10.     cout << "\nQual a quantidade de notas: ";
  11.     cin >> qtde;
  12.    
  13.     notas = new int[qtde]; // alocar na memoria
  14.  
  15.     for (int i=0; i < qtde; i++){
  16.         cout << "\nDigite a nota " << (i+1) << ": ";
  17.         cin >> *(notas+i);
  18.     }
  19.    
  20.     int soma = 0;
  21.     for (int i=0; i < qtde; i++){
  22.         soma += *(notas+i);
  23.     }    
  24.    
  25.     int media = soma / qtde;
  26.    
  27.     cout << "\n\nMedia: " << media;
  28.    
  29.     delete [] notas; // desalocar da memoria
  30.    
  31.  
  32.  
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment