Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _2020_03_24
  9. {
  10. class Program
  11. {
  12. static List<Helsinki> l = new List<Helsinki>();
  13. static List<string> sportagak = new List<string>();
  14. static void beolvassportagak()
  15. {
  16. for (int i = 0; i < l.Count; i++)
  17. {
  18. if (sportagak.Contains(l[i].sportag)==false)
  19. {
  20. sportagak.Add(l[i].sportag);
  21. }
  22. }
  23. }
  24.  
  25. static void beolvas()
  26. {
  27. StreamReader sr = new StreamReader("helsinki.txt");
  28. while (!sr.EndOfStream)
  29. {
  30. string sor = sr.ReadLine();
  31. string[] darabok = sor.Split(' ');
  32. Helsinki helsinki = new Helsinki();
  33. helsinki.helyezes = Convert.ToInt32(darabok[0]);
  34. helsinki.sportolokSzama = Convert.ToInt32(darabok[1]);
  35. helsinki.sportag = darabok[2];
  36. helsinki.versenyszam = darabok[3];
  37. l.Add(helsinki);
  38. }
  39. sr.Close();
  40. }
  41.  
  42. static void kiir()
  43. {
  44. for (int i = 0; i < l.Count; i++)
  45. {
  46. Console.Write(l[i].helyezes+" ");
  47. Console.Write(l[i].sportolokSzama+" ");
  48. Console.Write(l[i].sportag+" ");
  49. Console.Write(l[i].versenyszam+" ");
  50. Console.WriteLine();
  51. }
  52. }
  53.  
  54. static int ermekSzama()
  55. {
  56. int szamlalo = 0;
  57. for (int i = 0; i < l.Count; i++)
  58. {
  59. if (l[i].helyezes < 4)
  60. {
  61. szamlalo++;
  62. }
  63. }
  64. Console.WriteLine("Érmek száma");
  65. return szamlalo;
  66. }
  67.  
  68. static int uszasErmekSzama()
  69. {
  70. int szamlalo = 0;
  71. for (int i = 0; i < l.Count; i++)
  72. {
  73. if (l[i].helyezes < 4 && l[i].sportag=="uszas")
  74. {
  75. szamlalo++;
  76. }
  77. }
  78. Console.WriteLine("Úszás érmek száma");
  79. return szamlalo;
  80. }
  81.  
  82. static int tornaHelyezettekSzama()
  83. {
  84. int szamlalo = 0;
  85. for (int i = 0; i < l.Count; i++)
  86. {
  87. if (l[i].sportag=="torna")
  88. {
  89. szamlalo++;
  90. }
  91. }
  92. return szamlalo;
  93. }
  94. static int sportolokSzamaSportagra(string s)
  95. {
  96. int ossz = 0;
  97. for (int i = 0; i < l.Count; i++)
  98. {
  99. if (l[i].sportag==s)
  100. {
  101. ossz = ossz + l[i].sportolokSzama;
  102. }
  103. }
  104. return ossz;
  105. }
  106.  
  107. static int versenyszambanHelyezes(string v)
  108. {
  109. int h = 0;
  110. for (int i = 0; i < l.Count; i++)
  111. {
  112. if (l[i].versenyszam==v)
  113. {
  114. h = l[i].helyezes;
  115. }
  116. }
  117. return h;
  118. }
  119.  
  120. static bool sportagbanHelyezes(string s)
  121. {
  122. bool vanehelyezes = false;
  123. for (int i = 0; i < l.Count; i++)
  124. {
  125. if (l[i].sportag==s)
  126. {
  127. vanehelyezes = true;
  128. }
  129. }
  130. return vanehelyezes;
  131. }
  132.  
  133. static int sportagbanPont(string s)
  134. {
  135. int ossz = 0;
  136. for (int i = 0; i < l.Count; i++)
  137. {
  138. if (l[i].sportag==s && l[i].helyezes == 1)
  139. {
  140. ossz+=7;
  141. }
  142.  
  143. if (l[i].sportag == s && l[i].helyezes == 2)
  144. {
  145. ossz += 5;
  146. }
  147.  
  148. if (l[i].sportag == s && l[i].helyezes == 3)
  149. {
  150. ossz += 4;
  151. }
  152.  
  153. if (l[i].sportag == s && l[i].helyezes == 4)
  154. {
  155. ossz += 3;
  156. }
  157.  
  158. if (l[i].sportag == s && l[i].helyezes == 5)
  159. {
  160. ossz += 2;
  161. }
  162.  
  163. if (l[i].sportag == s && l[i].helyezes == 6)
  164. {
  165. ossz += 1;
  166. }
  167. }
  168. return ossz;
  169. }
  170.  
  171. static string legkevesebbOlimpiaiPontMelyikSportagban()
  172. {
  173. int min = int.MaxValue;
  174. int poz = 0;
  175. for (int i = 0; i < sportagak.Count; i++)
  176. {
  177. if (sportagbanPont(sportagak[i]) < min)
  178. {
  179. min = sportagbanPont(sportagak[i]);
  180. poz = i;
  181. }
  182. }
  183. return sportagak[poz];
  184. }
  185.  
  186. static void eremSportagankent()
  187. {
  188. for (int i = 0; i < l.Count; i++)
  189. {
  190. bool vaneerem = false;
  191. if (l[i].helyezes < 4)
  192. {
  193. vaneerem = true;
  194. Console.WriteLine(l[i].sportag + " " + vaneerem);
  195. }
  196. else
  197. {
  198. vaneerem = false;
  199. Console.WriteLine(l[i].sportag + " " + vaneerem);
  200. }
  201. }
  202. }
  203.  
  204. static void Main(string[] args)
  205. {
  206. beolvas();
  207. beolvassportagak();
  208. kiir();
  209. Console.WriteLine(ermekSzama());
  210. Console.WriteLine(uszasErmekSzama());
  211. Console.WriteLine("Torna sportág sportolóinak száma: "+tornaHelyezettekSzama());
  212. Console.WriteLine("Az úszás sportág sportolóinak száma: "+sportolokSzamaSportagra("uszas"));
  213. Console.WriteLine("A parbajtor_csapat versenyszámban ez a helyezés található: "+versenyszambanHelyezes("parbajtor_csapat"));
  214. Console.WriteLine("Az úszás sportágban értünk-e el helyezést: "+sportagbanHelyezes("uszas"));
  215. Console.WriteLine("Az atlétika sportágban "+sportagbanPont("atletika")+" pontot szereztünk");
  216. Console.WriteLine("A sportág, amiben a legkevesebb pontot értük el: "+legkevesebbOlimpiaiPontMelyikSportagban());
  217. eremSportagankent();
  218. Console.ReadKey();
  219. }
  220.  
  221.  
  222. }
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement