Advertisement
Guest User

codes

a guest
Dec 2nd, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1.         // game loop
  2.         while (true)
  3.         {
  4.             int maxVal = -1;
  5.             int maxIndex = 0;
  6.             for (int i = 0; i < 8; i++)
  7.             {
  8.                 int mountainH = int.Parse(Console.ReadLine()); // represents the height of one mountain.
  9.                 if(mountainH > maxVal)
  10.                 {
  11.                     maxVal = mountainH;
  12.                     maxIndex = i;
  13.                 }
  14.             }
  15.  
  16.             // Write an action using Console.WriteLine()
  17.             // To debug: Console.Error.WriteLine("Debug messages...");
  18.  
  19.             Console.WriteLine(maxIndex); // The index of the mountain to fire on.
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement