Advertisement
Guest User

Beers

a guest
Jun 23rd, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8.  
  9. class Beers
  10. {
  11.     static void Main()
  12.     {
  13.         string[] input = Console.ReadLine().Split(' ');
  14.         int beers = 0;
  15.         int stacks = 0;
  16.  
  17.         while (input[0] != "End")
  18.         {
  19.             if (input[1] == "beers")
  20.             {
  21.                 beers += Int32.Parse(input[0]);
  22.             }
  23.             else
  24.             {
  25.                 stacks += int.Parse(input[0]);
  26.             }
  27.             input = Console.ReadLine().Split(' ');
  28.         }
  29.         stacks += beers / 20;
  30.         beers %= 20;
  31.         Console.WriteLine("{0} stacks + {1} beers", stacks, beers);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement