Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double media (int *vetor, int n, int tam);
- int main(int argc, char** argv)
- {
- int tamanho;
- cout << "\nDigite o tamanho do vetor: ";
- cin >> tamanho;
- int vetor[tamanho];
- cout << endl;
- for (int i = 0; i < tamanho; i++)
- {
- cin >> vetor[i];
- }
- cout << "\nMedia: " << media(vetor, tamanho, tamanho) << endl;;
- return 0;
- }
- double media (int *vetor, int n, int tam)
- {
- if (n <= 0)
- {
- return 0;
- }
- else
- {
- return vetor[n - 1] / (float)tam + media(vetor, n - 1, tam);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement