#include <stdio.h>
#define DIAS_SEMANA 7
#define SUELDO_BASE 800
float calcular_ganancia( int prendas) {
// ... misma lógica que antes ...
}
int main( ) {
int ventas[ DIAS_SEMANA] ;
float sueldoTotal = SUELDO_BASE;
// Leer las ventas diarias
printf ( "Ingrese las ventas diarias de la semana:\n " ) ; for ( int i = 0 ; i < DIAS_SEMANA; i++ ) {
}
// Ordenar las ventas (usando el método de burbuja como ejemplo)
for ( int i = 0 ; i < DIAS_SEMANA - 1 ; i++ ) {
for ( int j = 0 ; j < DIAS_SEMANA - i - 1 ; j++ ) {
if ( ventas[ j] < ventas[ j + 1 ] ) {
int temp = ventas[ j] ;
ventas[ j] = ventas[ j + 1 ] ;
ventas[ j + 1 ] = temp;
}
}
}
// Calcular el sueldo total
for ( int i = 0 ; i < DIAS_SEMANA; i++ ) {
sueldoTotal += ventas[ i] * calcular_ganancia( ventas[ i] ) ;
}
// Imprimir las ventas ordenadas y el sueldo total
printf ( "Ventas ordenadas (de mayor a menor): " ) ; for ( int i = 0 ; i < DIAS_SEMANA; i++ ) {
}
printf ( "Sueldo total de la semana: $%.2f\n " , sueldoTotal
) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIERJQVNfU0VNQU5BIDcKI2RlZmluZSBTVUVMRE9fQkFTRSA4MDAKCmZsb2F0IGNhbGN1bGFyX2dhbmFuY2lhKGludCBwcmVuZGFzKSB7CiAgICAvLyAuLi4gbWlzbWEgbMOzZ2ljYSBxdWUgYW50ZXMgLi4uCn0KCmludCBtYWluKCkgewogICAgaW50IHZlbnRhc1tESUFTX1NFTUFOQV07CiAgICBmbG9hdCBzdWVsZG9Ub3RhbCA9IFNVRUxET19CQVNFOwoKICAgIC8vIExlZXIgbGFzIHZlbnRhcyBkaWFyaWFzCiAgICBwcmludGYoIkluZ3Jlc2UgbGFzIHZlbnRhcyBkaWFyaWFzIGRlIGxhIHNlbWFuYTpcbiIpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBESUFTX1NFTUFOQTsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCJEw61hICVkOiAiLCBpICsgMSk7CiAgICAgICAgc2NhbmYoIiVkIiwgJnZlbnRhc1tpXSk7CiAgICB9CgogICAgLy8gT3JkZW5hciBsYXMgdmVudGFzICh1c2FuZG8gZWwgbcOpdG9kbyBkZSBidXJidWphIGNvbW8gZWplbXBsbykKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgRElBU19TRU1BTkEgLSAxOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IERJQVNfU0VNQU5BIC0gaSAtIDE7IGorKykgewogICAgICAgICAgICBpZiAodmVudGFzW2pdIDwgdmVudGFzW2ogKyAxXSkgewogICAgICAgICAgICAgICAgaW50IHRlbXAgPSB2ZW50YXNbal07CiAgICAgICAgICAgICAgICB2ZW50YXNbal0gPSB2ZW50YXNbaiArIDFdOwogICAgICAgICAgICAgICAgdmVudGFzW2ogKyAxXSA9IHRlbXA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgLy8gQ2FsY3VsYXIgZWwgc3VlbGRvIHRvdGFsCiAgICBmb3IgKGludCBpID0gMDsgaSA8IERJQVNfU0VNQU5BOyBpKyspIHsKICAgICAgICBzdWVsZG9Ub3RhbCArPSB2ZW50YXNbaV0gKiBjYWxjdWxhcl9nYW5hbmNpYSh2ZW50YXNbaV0pOwogICAgfQoKICAgIC8vIEltcHJpbWlyIGxhcyB2ZW50YXMgb3JkZW5hZGFzIHkgZWwgc3VlbGRvIHRvdGFsCiAgICBwcmludGYoIlZlbnRhcyBvcmRlbmFkYXMgKGRlIG1heW9yIGEgbWVub3IpOiAiKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgRElBU19TRU1BTkE7IGkrKykgewogICAgICAgIHByaW50ZigiJWQgIiwgdmVudGFzW2ldKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKCiAgICBwcmludGYoIlN1ZWxkbyB0b3RhbCBkZSBsYSBzZW1hbmE6ICQlLjJmXG4iLCBzdWVsZG9Ub3RhbCk7CgogICAgcmV0dXJuIDA7Cn0=