Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void min(int n)
- {
- int t50, t20, t10, t5, t2, t1,min,dem=0,b[100],i,soto;
- for (t50 = 0;t50 < (n / 50);t50++)
- {
- for (t20 = 0;t20 < (n / 20);t20++)
- {
- for (t10 = 0;t10 < (n / 10);t10++)
- {
- for (t5 = 0;t5 < (n / 5);t5++)
- {
- for (t2 = 0;t2 < (n / 2);t2++)
- {
- for (t1 = 0;t1 < (n / 1);t1++)
- {
- if ((t50 * 50 + t20 * 20 + t10 * 10 + t5 * 5 + t2 * 2 + t1 * 1) == n)
- {
- soto = t50 + t20 + t10 + t5 + t2 + t1;
- dem++;
- b[dem] = soto;
- }
- }
- }
- }
- }
- }
- }
- min = b[1];
- for (i = 1;i < dem;i++)
- {
- if (b[i] < b[1])
- min = b[i];
- }
- cout << "so to it nhat la " << min << endl;
- }
- int main()
- {
- int n;
- cout << "nhap so tien la: ";
- cin >> n;
- min(n);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment