public static void countbills(int amount, int[] bills, int[] billsCount) { int remainder = amount; int billIterator = 1; for(int i = 0; i < billsCount.Length; i++) // while(remainder > 0) { //if(remainder >= bills[billIterator]) //{ if(billsCount[]) } if (remainder >= bills[i]) { if (billsCount[i] != 0) { billsCount[i]--; remainder -= bills[billIterator];//bills[i] * billsCount[billIterator]; billIterator++; //= bills[i];//amount / bills[i]; //remainder -= counts[bill] * dollarSizes[bill]; //reminder = amount % cashBills[billrem]; //amount -= billsCount[i] * bills[i]; //billsCount[i]--; } } } }
public static void Countsolve(int amount, int[] arraycount) { int[] cash = { 100, 50, 20, 10, 5, 1 }; int[] bcounter = { 0, 0, 0, 0, 0, 0 }; for(int i = 0; i < 6; i++) { if(amount >= cash[i]) { counter[i] = amount / cash[i]; amount -= bcounter[i] * cash[i]; } } for(int x=0; x<arraycount.Length; x++) { arraycount[x] = arraycount[x] - bcounter[x]; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)