YAMILDIAZ

Untitled

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