Advertisement
konevLOX

7.3.2

Nov 30th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. class Teams
  2. {
  3. public double points;
  4. }
  5. class Teams1 : Teams
  6. {
  7. public string name;
  8. public Teams1(string name, double points)
  9. {
  10. this.points = points;
  11. this.name = name;
  12. }
  13. }
  14.  
  15. class Program
  16. {
  17. static void Up(Teams1[] x)
  18. {
  19. for (int i = 0; i < x.Length - 1; i++)
  20. {
  21. double xmax = x[i].points;
  22. int imax = i;
  23. for (int j = i + 1; j < x.Length; j++)
  24. {
  25. if (x[j].points > xmax)
  26. {
  27. xmax = x[j].points;
  28. imax = j;
  29. }
  30. }
  31. Teams1 temp;
  32. temp = x[imax];
  33. x[imax] = x[i];
  34. x[i] = temp;
  35. }
  36. }
  37. static void Main(string[] args)
  38. {
  39. Teams1[] group1 = new Teams1[4];
  40. group1[0] = new Teams1("Atletico", 37);
  41. group1[1] = new Teams1("Real", 29);
  42. group1[2] = new Teams1("Barcelona", 41);
  43. group1[3] = new Teams1("CSKA", 34);
  44. Teams1[] group2 = new Teams1[4];
  45. group2[0] = new Teams1("Spartak", 35);
  46. group2[1] = new Teams1("Zenit", 29);
  47. group2[2] = new Teams1("Arsenal", 33);
  48. group2[3] = new Teams1("Akhmat", 27);
  49. Up(group1);
  50. Up(group2);
  51. Teams1[] mainGroup = new Teams1[(group1.Length + group2.Length) / 2];
  52. for (int i = 0; i < mainGroup.Length; i += 2)
  53. {
  54. mainGroup[i] = group1[i / 2];
  55. mainGroup[i + 1] = group2[i / 2];
  56. }
  57. for (int i = 0; i < 4; i++)
  58. WriteLine(mainGroup[i].name);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement