anizko

Coint - проблем с часовник

Apr 4th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Coins
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double Money = double .Parse(Console.ReadLine());
  10.             double Resto = Money * 100;
  11.             double countCoint = 0;
  12.  
  13.             while(Resto>0)
  14.             {
  15.                 if(Resto>=200)
  16.                 {
  17.                     countCoint = Math.Truncate(Resto / 200);
  18.                     Resto = Resto % 200;
  19.                 }
  20.                 else if (Resto >= 100 && Resto < 200)
  21.                 {
  22.                     countCoint += Math.Truncate(Resto / 100);
  23.                     Resto = Resto % 100;
  24.                 }
  25.                 else if (Resto >= 50 && Resto < 100)
  26.                 {
  27.                     countCoint += Math.Truncate(Resto /50);
  28.                     Resto = Resto % 50;
  29.                 }
  30.                 else if (Resto >= 20 && Resto < 50)
  31.                 {
  32.                     countCoint += Math.Truncate(Resto / 20);
  33.                     Resto = Resto % 20;
  34.                 }
  35.                 else if (Resto >= 10 && Resto < 20)
  36.                 {
  37.                     countCoint += Math.Truncate(Resto / 10);
  38.                     Resto = Resto % 10;
  39.                 }
  40.                 else if (Resto >= 5 && Resto < 10)
  41.                 {
  42.                     countCoint += Math.Truncate(Resto / 5);
  43.                     Resto = Resto % 5;
  44.                 }
  45.                 else if (Resto >= 2 && Resto < 5)
  46.                 {
  47.                     countCoint += Math.Truncate(Resto / 2);
  48.                     Resto = Resto % 2;
  49.                 }
  50.                 else if (Resto == 1)
  51.                 {
  52.                     countCoint++;
  53.                     break;
  54.                 }
  55.             }
  56.  
  57.  
  58.             Console.WriteLine(countCoint);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment