Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] coins = { 50, 20, 10, 5, 2, 1 };
- Console.Write("Enter suma: ");
- int sum = int.Parse(Console.ReadLine());
- int i = 0;
- /*
- while (sum != 0)
- {
- while (sum - coins[i] >= 0)
- {
- sum -= coins[i];
- Console.Write("{0}, ", coins[i]);
- }
- i++;
- }
- */
- int s = 0;
- while (sum != s)
- {
- while (s + coins[i] <= sum)
- {
- s += coins[i];
- Console.Write("{0}, ", coins[i]);
- }
- i++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement