fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int amount;
  7. cout << "Ingrese la cantidad de dinero: ";
  8. cin >> amount;
  9.  
  10. // Denominaciones de los billetes
  11. int denominations[] = {50, 20, 10, 5, 1};
  12. int size = sizeof(denominations) / sizeof(denominations[0]);
  13.  
  14. // Vector para almacenar los billetes
  15. vector<int> banknotes;
  16.  
  17. // Calcular los billetes necesarios
  18. for (int i = 0; i < size; i++) {
  19. while (amount >= denominations[i]) {
  20. banknotes.push_back(denominations[i]);
  21. amount -= denominations[i];
  22. }
  23. }
  24.  
  25. // Mostrar los billetes
  26. for (int i = 0; i < banknotes.size(); i++) {
  27. cout << banknotes[i] << " ";
  28. }
  29. cout << endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Ingrese la cantidad de dinero: 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 20 20 5