Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float promedio(int valores[], int n) {
- float suma = 0.0;
- for (int i = 0; i < n; i++) {
- suma += valores[i];
- }
- return suma / n;
- }
- float suma_cuadrados(int valores[], int n) {
- float suma = 0.0;
- for (int i = 0; i < n; i++) {
- suma += pow(valores[i],2);
- }
- return suma;
- }
- int mayor(int valores[], int n) {
- int val_mayor=valores[0];
- for (int i = 1; i < n; i++)
- if (val_mayor < valores[i])
- val_mayor = valores[i];
- return val_mayor;
- }
- int main()
- {
- int * valores;
- valores = new int[5];
- for (int i = 0; i < 5; i++) {
- cin >> valores[i];
- }
- cout << mayor(valores, 5) <<endl;
- cout << promedio(valores, 5) << endl;
- cout << suma_cuadrados(valores, 5) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement