Skip to content

Instantly share code, notes, and snippets.

@sjsakib
Last active February 22, 2016 05:51
Show Gist options
  • Save sjsakib/49ea7dc8dbd5b18f8e0e to your computer and use it in GitHub Desktop.
Save sjsakib/49ea7dc8dbd5b18f8e0e to your computer and use it in GitHub Desktop.
int coin[] = {50,20,10,5,2,1};
int return_change(int amount) {
int res = 0;
int j = 0;
while(amount>0) {
if(amount<=coin[j]) {
amount-=coin[j];
res++;
} else {
if(j == 6) { //নোট বা কয়েন শেষ কিন্তু টাকা শেষ হয়নি। তাহলে ভাংতি দেয়া যাবে না
res = -1;
break;
} else {
j++;
}
}
}
cout<<res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment