fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. return 0;
  7. }
Success #stdin #stdout 0s 5324KB
stdin
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

struct Vendedor {
    string nombre;
    int ventas[7]; // Ventas de lunes a domingo
};

double calcularSueldoTotal(int ventas[]) {
    const double sueldoBase = 800.0;
    double comisionTotal = 0.0;

    for (int i = 0; i < 7; ++i) {
        double comisionPorPrenda = 0.0;
        if (ventas[i] <= 50) {
            comisionPorPrenda = 2.00;
        } else if (ventas[i] <= 100) {
            comisionPorPrenda = 3.50;
        } else {
            comisionPorPrenda = 5.00;
        }
        comisionTotal += ventas[i] * comisionPorPrenda;
    }

    return sueldoBase + comisionTotal;
}

void ordenarVentas(int ventas[]) {
    sort(ventas, ventas + 7, greater<int>());
}

int main() {
    Vendedor vendedores[] = {
        {"Juan Pérez", {45, 60, 70, 80, 90, 100, 110}},
        {"Ana Gómez", {30, 40, 50, 60, 70, 80, 90}},
        {"Luis Martínez", {20, 30, 40, 50, 60, 70, 80}}
    };

    cout << fixed << setprecision(2);

    for (auto& v : vendedores) {
        ordenarVentas(v.ventas);
        double sueldoTotal = calcularSueldoTotal(v.ventas);
        cout << "Vendedor: " << v.nombre << endl;
        cout << "Ventas ordenadas: ";
        for (int i = 0; i < 7; ++i) {
            cout << v.ventas[i] << " ";
        }
        cout << endl;
        cout << "Sueldo Total: $" << sueldoTotal << endl;
        cout << "-----------------------------" << endl;
    }

    return 0;
}
stdout
Standard output is empty