Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float promedio(int valores[], int n) {
  5.     float suma = 0.0;
  6.     for (int i = 0; i < n; i++) {
  7.         suma += valores[i];
  8.     }
  9.     return suma / n;
  10. }
  11.  
  12. float suma_cuadrados(int valores[], int n) {
  13.     float suma = 0.0;
  14.     for (int i = 0; i < n; i++) {
  15.         suma += pow(valores[i],2);
  16.     }
  17.     return suma;
  18. }
  19.  
  20. int mayor(int valores[], int n) {
  21.     int val_mayor=valores[0];
  22.     for (int i = 1; i < n; i++)
  23.         if (val_mayor < valores[i])
  24.             val_mayor = valores[i];
  25.     return val_mayor;
  26. }
  27. int main()
  28. {
  29.     int * valores;
  30.     valores = new int[5];
  31.     for (int i = 0; i < 5; i++) {
  32.         cin >> valores[i];
  33.     }
  34.     cout << mayor(valores, 5) <<endl;
  35.     cout << promedio(valores, 5) << endl;
  36.     cout << suma_cuadrados(valores, 5) << endl;
  37.     system("pause");
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement