Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Coins_MyTry
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal change = decimal.Parse(Console.ReadLine());
- change = change * 100;
- decimal coins = 0;
- decimal dveSt = 0;
- decimal dvadesetSt = 0;
- while (change > 0)
- {
- decimal dvaLeva = Math.Truncate(change / 200);
- if (change >= 200)
- {
- if(dvaLeva==1)
- {
- coins++;
- change -= 200;
- }
- }
- if (change >= 100)
- {
- decimal edinLev = Math.Truncate(change / 100);
- if(edinLev==1)
- {
- coins++;
- change -= 100;
- }
- }
- if (change >=50)
- {
- decimal petdesetSt = Math.Truncate(change / 50);
- if(petdesetSt==1)
- {
- coins++;
- change -= 50;
- }
- }
- if (change >=20)
- {
- dvadesetSt = Math.Truncate(change / 20);
- if(dvadesetSt==1)
- {
- change -= 20;
- }
- else if (dvadesetSt == 2)
- {
- change -= 40;
- }
- }
- if (change >=10)
- {
- decimal desetSt = Math.Truncate(change / 10);
- if(desetSt==1)
- {
- coins++;
- change -= 10;
- }
- }
- if (change >=5)
- {
- decimal petSt = Math.Truncate(change / 5);
- if(petSt==1)
- {
- coins++;
- change -= 5;
- }
- }
- if (change >=2)
- {
- dveSt = Math.Truncate(change / 2);
- if(dveSt==1)
- {
- change -= 2;
- }
- else if (dveSt == 2)
- {
- change -= 4;
- }
- }
- if (change > 0)
- {
- coins++;
- break;
- }
- }
- Console.WriteLine(coins+dveSt+dvadesetSt);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement