#include <stdio.h>
int main() {
int total, nota1, nota2, notas1, notas2;
// Entrada dos valores
printf("Digite o valor total a ser sacado: "); printf("Digite o valor da primeira nota: "); printf("Digite o valor da segunda nota: ");
// Troca os valores se nota2 for maior que nota1
if (nota2 > nota1) {
int aux = nota1;
nota1 = nota2;
nota2 = aux;
}
// Calcula a quantidade de notas de cada tipo
notas1 = total / nota1;
total = total - (notas1 * nota1);
notas2 = total / nota2;
// Ajusta a quantidade de notas se necessário
if (notas2 == 0) {
notas1 = notas1 - 1;
notas2 = nota1 / nota2;
}
// Imprime o resultado
printf("Notas de %d: %d\n", nota1
, notas1
); printf("Notas de %d: %d\n", nota2
, notas2
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCB0b3RhbCwgbm90YTEsIG5vdGEyLCBub3RhczEsIG5vdGFzMjsKCiAgICAvLyBFbnRyYWRhIGRvcyB2YWxvcmVzCiAgICBwcmludGYoIkRpZ2l0ZSBvIHZhbG9yIHRvdGFsIGEgc2VyIHNhY2FkbzogIik7CiAgICBzY2FuZigiJWQiLCAmdG90YWwpOwogICAgcHJpbnRmKCJEaWdpdGUgbyB2YWxvciBkYSBwcmltZWlyYSBub3RhOiAiKTsKICAgIHNjYW5mKCIlZCIsICZub3RhMSk7CiAgICBwcmludGYoIkRpZ2l0ZSBvIHZhbG9yIGRhIHNlZ3VuZGEgbm90YTogIik7CiAgICBzY2FuZigiJWQiLCAmbm90YTIpOwoKICAgIC8vIFRyb2NhIG9zIHZhbG9yZXMgc2Ugbm90YTIgZm9yIG1haW9yIHF1ZSBub3RhMQogICAgaWYgKG5vdGEyID4gbm90YTEpIHsKICAgICAgICBpbnQgYXV4ID0gbm90YTE7CiAgICAgICAgbm90YTEgPSBub3RhMjsKICAgICAgICBub3RhMiA9IGF1eDsKICAgIH0KCiAgICAvLyBDYWxjdWxhIGEgcXVhbnRpZGFkZSBkZSBub3RhcyBkZSBjYWRhIHRpcG8KICAgIG5vd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