hi6tnikyt87

Everest

Aug 18th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. int baseCamp = 5364;
  2. int mountEverest = 8848;
  3. int maxDays = 5;
  4.  
  5. int current = baseCamp;
  6. int daysWithoutRelax = 0;
  7. int totalDays = 1;
  8.  
  9. string input = Console.ReadLine();
  10.  
  11.  
  12.  
  13.  
  14. while (input != "END" && totalDays < maxDays)
  15. {
  16.     if (input == "Yes")
  17.     {
  18.         totalDays++;
  19.     }
  20.     else if (input == "No")
  21.     {
  22.         daysWithoutRelax++;
  23.     }
  24.  
  25.     int nextMeters = int.Parse(Console.ReadLine());
  26.     current += nextMeters;
  27.  
  28.     if (current >= mountEverest)
  29.     {
  30.         break;
  31.     }
  32.  
  33.     input = Console.ReadLine();
  34. }
  35.  
  36. if (current >= mountEverest)
  37. {
  38.     Console.WriteLine($"Goal reached for {totalDays} days!");
  39. }
  40. else
  41. {
  42.     Console.WriteLine("Failed!");
  43.     Console.WriteLine($"{current}");
  44. }
Advertisement
Add Comment
Please, Sign In to add comment