Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 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. using System.IO;
  7.  
  8. namespace prglistatitanic
  9. {
  10. class helsinki_tip
  11. {
  12. public int helyezes, csapattagokszama;
  13. public string sportag, versenyszam;
  14. public helsinki_tip(string sor)
  15. {
  16. string[] darabolt = sor.Split(' ');
  17. this.helyezes = int.Parse(darabolt[0]);
  18. this.csapattagokszama = int.Parse(darabolt[1]);
  19. this.sportag = darabolt[2];
  20. this.versenyszam = darabolt[3];
  21.  
  22.  
  23. }
  24. }
  25. class Program
  26. {
  27. static void Main(string[] args)
  28. {
  29. List<helsinki_tip> helsinki = new List<helsinki_tip>();
  30. StreamReader f = new StreamReader("helsinki.txt");
  31. while (!f.EndOfStream)
  32. {
  33. helsinki.Add(new helsinki_tip(f.ReadLine()));
  34. }
  35. Console.WriteLine("3.feladat:\n" + helsinki.Count + "db");
  36. int pontszerzohelyek = 0;
  37. foreach (helsinki_tip elem in helsinki)
  38. pontszerzohelyek += elem.helyezes;
  39. int elso = 0;
  40. int masodik = 0;
  41. int harmadik = 0;
  42. for (int i = 0; i < helsinki.Count; i++)
  43. {
  44. if (helsinki[i].helyezes == 1)
  45. {
  46. elso++;
  47. }
  48. }
  49. for (int i = 0; i < helsinki.Count; i++)
  50. {
  51. if (helsinki[i].helyezes == 2)
  52. {
  53. masodik++;
  54. }
  55. }
  56. for (int i = 0; i < helsinki.Count; i++)
  57. {
  58. if (helsinki[i].helyezes == 3)
  59. {
  60. harmadik++;
  61. }
  62. }
  63. int ossz = masodik + elso + harmadik;
  64.  
  65.  
  66. Console.WriteLine("4.Feladat:\nArany:{0}\nEzüst{1}\nBronz{2}\nÖssz:{3}", elso, masodik, harmadik, ossz);
  67. int egy = 0;
  68. int ketto = 0;
  69. int harom = 0;
  70. int negy = 0;
  71. int ot = 0;
  72. int hat = 0;
  73. for (int i = 0; i < helsinki.Count; i++)
  74. {
  75. if (helsinki[i].helyezes == 1)
  76. {
  77. egy += 7;
  78. }
  79. if (helsinki[i].helyezes == 2)
  80. {
  81. ketto += 5;
  82. }
  83. if (helsinki[i].helyezes == 3)
  84. {
  85. harom += 4;
  86. }
  87. if (helsinki[i].helyezes == 4)
  88. {
  89. negy += 3;
  90. }
  91. if (helsinki[i].helyezes == 5)
  92. {
  93. ot += 2;
  94. }
  95. if (helsinki[i].helyezes == 6)
  96. {
  97. hat += 1;
  98. }
  99. }
  100. Console.WriteLine("5.Feladat:\nElért Olimpiai pontok száma:{0}", egy + ketto + harom + negy + ot + hat);
  101. Console.ReadKey();
  102.  
  103. }
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement