Advertisement
Mike_Goodman92

Untitled

Oct 29th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 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 Problem_4.Trifon_s_Quest
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. long hp = Math.Abs(int.Parse(Console.ReadLine()));
  14. // long maxhp = hp; // дали да има нещо като максимално hp което не може да преминава ??? // Оказва се че не иска да има максималнo hp
  15.  
  16. string[] matrix = Console.ReadLine().Split(' ');
  17. string[,] gamematrix = new string[int.Parse(matrix[0]), int.Parse(matrix[1])];
  18.  
  19. for (int rows = 0; rows < int.Parse(matrix[0]); rows++)
  20. {
  21. string lineMap = Console.ReadLine(); // FFFF
  22.  
  23. for (int cols = 0; cols < int.Parse(matrix[1]); cols++)
  24. {
  25. gamematrix[rows, cols] = lineMap[cols].ToString();
  26. }
  27.  
  28. }
  29.  
  30. int countTurn = 0; // отчита броя на входовете
  31.  
  32. for (int cols = 0; cols < int.Parse(matrix[1]); cols++)
  33. {
  34. if (cols % 2 == 0)
  35. {
  36. for (int rows = 0; rows < int.Parse(matrix[0]); rows++)
  37. {
  38. switch (gamematrix[rows, cols])
  39. {
  40. case "F":
  41. hp -= countTurn / 2; /*if (hp <= 0) { hp = 0; */ // не е нужно да се изписва накрая hp
  42.  
  43. if (hp <= 0)
  44. {
  45. Console.WriteLine($"Died at: [{rows}, {cols}]");
  46. //Environment.Exit(0); // спира цялата програма
  47. return;
  48. }
  49. ; break;
  50. case "H": hp += countTurn / 3/* ; if (hp > maxhp) { hp = maxhp; }*/; break;
  51. case "T": countTurn += 2; if (countTurn <= 0) { countTurn = 1; }; break;
  52. }
  53.  
  54. // Console.WriteLine($"Current turn: [{rows}][{cols}] => {gamematrix[rows, cols]} -> {hp} hp left : turn -> {countTurn}");
  55. countTurn++;
  56. }
  57. }
  58.  
  59. if (cols % 2 == 1)
  60. {
  61. for (int rows = int.Parse(matrix[0]) - 1; rows >= 0; rows--)
  62. {
  63. switch (gamematrix[rows, cols])
  64. {
  65. case "F":
  66. hp -= countTurn / 2; /*if (hp <= 0) { hp = 0; */
  67.  
  68. if (hp <= 0)
  69. {
  70. Console.WriteLine($"Died at: [{rows}, {cols}]");
  71. //Environment.Exit(0); // спира цялата програма
  72. return;
  73. }
  74. ; break;
  75. case "H": hp += countTurn / 3/* ; if (hp > maxhp) { hp = maxhp; }*/; break;
  76. case "T": countTurn += 2; if (countTurn <= 0) { countTurn = 1; }; break;
  77. }
  78.  
  79. // Console.WriteLine($"Current turn: [{rows}][{cols}] => {gamematrix[rows, cols]} -> {hp} hp left : turn -> {countTurn}");
  80. countTurn++;
  81. }
  82. }
  83.  
  84.  
  85. }
  86.  
  87. // Output :
  88. if (hp > 0)
  89. {
  90. Console.WriteLine("Quest completed!");
  91. Console.WriteLine($"Health: {hp}");
  92. Console.WriteLine($"Turns: {countTurn}");
  93. }
  94.  
  95.  
  96.  
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement