YAMILDIAZ

punto C 2do parcial

Jul 17th, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5.  
  6. void cargarDatos(float mPromedio[7][2]);
  7. void Punto3(float mPromedio[7][2]);
  8.  
  9. int main(){
  10.  
  11. //punto C
  12. float mPromedio[7][2]={};
  13.  
  14. cargarDatos(mPromedio);
  15. cout<<endl;
  16. Punto3(mPromedio);
  17.  
  18.  
  19. system("pause");
  20. return 0;
  21. }
  22. void cargarDatos(float mPromedio[7][2]){
  23.  
  24. int numVenta, generoLiterario;
  25. float precio;
  26.  
  27. cout<<"numero de venta: ";
  28. cin>>numVenta;
  29.  
  30. while(numVenta != 0){
  31.     cout<<"Genero Literario: ";
  32.     cin>>generoLiterario;
  33.     cout<<"Precio: ";
  34.     cin>>precio;
  35.  
  36.     //punto 3
  37.     mPromedio[generoLiterario-1][0]+=precio;
  38.     mPromedio[generoLiterario-1][1]++;
  39.  
  40.     cout<<endl;
  41.     cout<<"numero de venta: ";
  42.     cin>>numVenta;
  43. }
  44.  
  45. }
  46. void Punto3(float mPromedio[7][2]){
  47.     string genero[7]={"Terror", "Biografia", "Novela", "Ciencia ficcion", "Historia", "Ciencia", "Salud"};
  48.     int i;
  49.     float promedio;
  50.  
  51.     for(i = 0; i < 7; i++){
  52.         promedio= mPromedio[i][0]/mPromedio[i][1];
  53.         if(promedio > 0){
  54.             cout<<genero[i]<<": "<<promedio<<endl;
  55.         }else{
  56.             cout<<genero[i]<<": no hubo venta de ese genero literario"<<endl;
  57.  
  58.         }
  59.     }
  60.  
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment