Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int qtde;
- int *notas;
- cout << "\nQual a quantidade de notas: ";
- cin >> qtde;
- notas = new int[qtde]; // alocar na memoria
- for (int i=0; i < qtde; i++){
- cout << "\nDigite a nota " << (i+1) << ": ";
- cin >> *(notas+i);
- }
- int soma = 0;
- for (int i=0; i < qtde; i++){
- soma += *(notas+i);
- }
- int media = soma / qtde;
- cout << "\n\nMedia: " << media;
- delete [] notas; // desalocar da memoria
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment