braveheart1989

Volleyball

Feb 11th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _10.Volleyball
  8. {
  9.     class Volleyball
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //•   Първият ред съдържа думата “leap” (високосна година) или “normal” (невисокосна).
  14.             string years =Console.ReadLine().ToLower();
  15.             //•   Вторият ред съдържа цялото число p – брой празници в годината (които не са събота и неделя).
  16.             int weekendsInYear = int.Parse(Console.ReadLine());
  17.             //•   Третият ред съдържа цялото число h – брой уикенди, в които Влади си пътува до родния град.
  18.             int weekendCount = int.Parse(Console.ReadLine());
  19.             double allAmountOfGames = 0;
  20.             double weekendsGames = 0;
  21.             double allWeekendsInYear = (48.0 - weekendCount) * (3.0 / 4.0);
  22.             switch (years)
  23.             {
  24.                 case "leap": weekendsGames = weekendsInYear * (2.0 / 3.0);
  25.                     weekendsGames += allWeekendsInYear + weekendCount;
  26.                     double weekendsleapGames = weekendsGames * 0.15;
  27.                     allAmountOfGames = Math.Floor(weekendsleapGames + weekendsGames);
  28.                     Console.WriteLine(allAmountOfGames);
  29.                     break;
  30.                 case "normal": weekendsGames = weekendsInYear * (2.0 / 3.0);
  31.                     weekendsGames += allWeekendsInYear + weekendCount;
  32.                     allAmountOfGames = Math.Floor(weekendsGames);
  33.                     Console.WriteLine(allAmountOfGames);
  34.                     break;
  35.                 default:
  36.                     break;
  37.             }
  38.  
  39.             //Втори начин:
  40.             //double allAmountOfGames = 0;
  41.             //double weekendsGames = 0;
  42.             //double allWeekendsInYear = (48.0 - weekendCount) * (3.0/4.0);
  43.  
  44.             //if (years=="leap")
  45.             //{
  46.             //    weekendsGames = weekendsInYear * (2.0 / 3.0);
  47.             //    weekendsGames += allWeekendsInYear+ weekendCount;
  48.             //    double weekendsleapGames = weekendsGames * 0.15;
  49.             //    allAmountOfGames = Math.Floor(weekendsleapGames + weekendsGames);
  50.             //    Console.WriteLine(allAmountOfGames);
  51.             //}
  52.             //else
  53.             //{
  54.             //    weekendsGames  = weekendsInYear * (2.0 / 3.0);
  55.             //    weekendsGames += allWeekendsInYear + weekendCount;
  56.             //    allAmountOfGames = Math.Floor(weekendsGames);
  57.             //    Console.WriteLine(allAmountOfGames);
  58.             //}
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment