I am trying to write some logic which allows me to store values into a 2 dimensional array. Within the function below, I would like to store the current coins[i] value, with the corresponding coin variable as a pair. However, I am not exactly sure how I can this can be done. Reason being is that I would like to loop through the array once it has been populated and print out the current coins[i] value along with the corresponding coin variable which indicates the amount of times used to dispense change.
Function:
int counter = 0;
int coin;
for (int i = 0; i < coins.Length; i++)
{
coin = Math.Min(quantities[i], (int)(change / coins[i]));
counter += coin;
change -= coin * coins[i];
// want to store [coins[i], coin] in an 2Darray
}
Console.WriteLine("Number of coins = {0}", counter);
If there is another way that this can be done, please be sure to provide suggestions. Bare in mind I cannot use anything from the Collection classes. All answers are appreciated.