Aliendreamer

hornet assault 50/100

May 23rd, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 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 programingFundamentalsExam26022017HornetArmada
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             string[] beehives = Console.ReadLine().Split(' ');
  15.             int[] beehivesInt = Array.ConvertAll(beehives, Int32.Parse);
  16.  
  17.             string[] hornets = Console.ReadLine().Split(' ');
  18.             int[] hornetsInt = Array.ConvertAll(hornets, Int32.Parse);
  19.  
  20.             List<int> alivebees = new List<int>();
  21.  
  22.             List<int> hornetsLeft = new List<int>(hornetsInt);
  23.  
  24.             int totalHornets = hornetsInt.Sum();
  25.  
  26.  
  27.             foreach (int item in beehivesInt)
  28.             {
  29.                
  30.                     if (item >= totalHornets)
  31.                     {
  32.                         int difference = item - totalHornets;
  33.  
  34.                     if(difference > 0)
  35.                     {
  36.                         alivebees.Add(difference);
  37.                     }
  38.  
  39.                         totalHornets = totalHornets - hornetsInt[0];
  40.  
  41.                         hornetsLeft.Remove(hornetsLeft[0]);
  42.                     }
  43.                     else if (item < totalHornets)
  44.                     {
  45.                         continue;
  46.  
  47.                     }
  48.  
  49.                     //  Console.WriteLine("{0}", alivebees.First());
  50.  
  51.                
  52.  
  53.             }
  54.  
  55.             if (alivebees.Count != 0)
  56.             {
  57.                 string otherfinal = "";
  58.                 foreach(int num in alivebees)
  59.                 {
  60.                    otherfinal=otherfinal +=num + " ";
  61.                 }
  62.                 Console.WriteLine($"{otherfinal}");
  63.  
  64.             }
  65.             else
  66.             {
  67.                 string final="";
  68.                 foreach (var survived in hornetsLeft)
  69.                 {
  70.                   final=final += survived + " ";
  71.                
  72.                     //     box = box += value + " ";
  73.  
  74.                 }
  75.                 Console.WriteLine("{0}",final);
  76.             }
  77.            
  78.  
  79.  
  80.  
  81.  
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment