iliya87

Beers

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