tranght

Untitled

Feb 14th, 2017
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void min(int n)
  4. {
  5. int t50, t20, t10, t5, t2, t1,min,dem=0,b[100],i,soto;
  6. for (t50 = 0;t50 < (n / 50);t50++)
  7. {
  8. for (t20 = 0;t20 < (n / 20);t20++)
  9. {
  10. for (t10 = 0;t10 < (n / 10);t10++)
  11. {
  12. for (t5 = 0;t5 < (n / 5);t5++)
  13. {
  14. for (t2 = 0;t2 < (n / 2);t2++)
  15. {
  16. for (t1 = 0;t1 < (n / 1);t1++)
  17. {
  18. if ((t50 * 50 + t20 * 20 + t10 * 10 + t5 * 5 + t2 * 2 + t1 * 1) == n)
  19. {
  20. soto = t50 + t20 + t10 + t5 + t2 + t1;
  21. dem++;
  22. b[dem] = soto;
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
  30. min = b[1];
  31. for (i = 1;i < dem;i++)
  32. {
  33. if (b[i] < b[1])
  34. min = b[i];
  35. }
  36. cout << "so to it nhat la " << min << endl;
  37. }
  38. int main()
  39. {
  40. int n;
  41. cout << "nhap so tien la: ";
  42. cin >> n;
  43. min(n);
  44. system("pause");
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment