#include #include using namespace std; int main() { const int troco = 387; int moedas[] = {100, 50, 25, 10, 5, 1}; int valor = 0; int moedasfinal = 0; for (int i = 0; i < 6; i++) { while (valor < troco) { valor += moedas[i]; moedasfinal += 1; if (valor > troco) { valor -= moedas[i]; moedasfinal -= 1; break; } else if (valor == troco) { cout << moedasfinal << endl; break; } } } return 0; }