Advertisement
Guest User

01

a guest
Jul 25th, 2014
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int s = int.Parse(Console.ReadLine());
  8.         int d = int.Parse(Console.ReadLine());
  9.         int waterMelons = 0, melons = 0, currentWatermelons, currentMelons;
  10.  
  11.         int currentDay = s;
  12.         for (int i = 0; i < d; i++)
  13.         {
  14.             currentWatermelons = 0;
  15.             currentMelons = 0;
  16.  
  17.             if (currentDay == 1)
  18.             {
  19.                 currentWatermelons = 1;
  20.                 currentMelons = 0;
  21.             }
  22.             else if (currentDay == 2)
  23.             {
  24.                 currentWatermelons = 0;
  25.                 currentMelons = 2;
  26.             }
  27.             else if (currentDay == 3)
  28.             {
  29.                 currentWatermelons = 1;
  30.                 currentMelons = 1;
  31.             }
  32.             else if (currentDay == 4)
  33.             {
  34.                 currentWatermelons = 2;
  35.                 currentMelons = 0;
  36.             }
  37.             else if (currentDay == 5)
  38.             {
  39.                 currentWatermelons = 2;
  40.                 currentMelons = 2;
  41.             }
  42.             else if (currentDay == 6)
  43.             {
  44.                 currentWatermelons = 1;
  45.                 currentMelons = 2;
  46.             }
  47.             else if (currentDay == 7)
  48.             {
  49.                 currentWatermelons = 0;
  50.                 currentMelons = 0;
  51.             }
  52.  
  53.             waterMelons += currentWatermelons;
  54.             melons += currentMelons;
  55.  
  56.             currentDay++;
  57.  
  58.             if (currentDay == 8)
  59.             {
  60.                 currentDay = 1;
  61.             }
  62.         }
  63.    
  64.         if(waterMelons > melons)
  65.         {
  66.             Console.WriteLine("{0} more watermelons", waterMelons - melons);
  67.         }
  68.         else if(melons > waterMelons)
  69.         {
  70.             Console.WriteLine("{0} more melons", melons - waterMelons);
  71.         }
  72.         else
  73.         {
  74.             Console.WriteLine("Equal amount: {0}", waterMelons);
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement