Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. //Realice un algoritmo con una función que le pedirá cíclicamente un dato al usuario durante n ciclos, la función calculará y retornará el promedio de los datos sin incluir el mayor ni el menor de los mismos, recibirá como parámetro el número de datos (ciclos) a ingresar.
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <iostream>
  5. using namespace std;
  6. int main(){
  7. int cantidad, numero, mayor, menor, suma;
  8. double promedio;
  9. cout<<"Ingrese la cantidad de números a ingresar"<<endl;
  10. cin>>cantidad;
  11. for(int j = 0; j < cantidad; j++){
  12. cout<<"Ingrese número: "<<j<<endl;
  13. cin>>numero;
  14. for(int i = 0; i < cantidad; i++){
  15. if(mayor < numero){
  16. mayor = numero;
  17. }
  18. }
  19. menor = mayor;
  20. for(int i = 0; i< cantidad; i++){
  21. if(menor > numero){
  22. menor = numero;
  23. }
  24. }
  25. suma += numero;
  26. }
  27. cout<<"El número mayor es: "<<mayor<<endl;
  28. cout<<"El número menor es: "<<menor<<endl;
  29. suma = numero - mayor - menor;
  30. promedio = suma/cantidad;
  31. cout<<"El promedio es: "<<promedio<<endl;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement