Advertisement
konevLOX

6.3.4

Dec 7th, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. struct Participant
  2. {
  3. public string famile;
  4. public double result;
  5. public Participant(string famile, double result)
  6. {
  7. this.famile = famile;
  8. this.result = result;
  9. }
  10. }
  11. class Program
  12. {
  13. static void Down(Participant[] x)
  14. {
  15. for (int i = 0; i < x.Length - 1; i++)
  16. {
  17. double xmin = x[i].result;
  18. int imin = i;
  19. for (int j = i + 1; j < x.Length; j++)
  20. {
  21. if (x[j].result < xmin)
  22. {
  23. xmin = x[j].result;
  24. imin = j;
  25. }
  26. }
  27. Participant temp;
  28. temp = x[imin];
  29. x[imin] = x[i];
  30. x[i] = temp;
  31. }
  32. }
  33. static void Main(string[] args)
  34. {
  35. Participant[] pc1 = new Participant[4];
  36. pc1[0] = new Participant("pukin", 5.48);
  37. pc1[1] = new Participant("vasin", 6.02);
  38. pc1[2] = new Participant("putin", 5.15);
  39. pc1[3] = new Participant("adolf", 4.44);
  40. Participant[] pc2 = new Participant[4];
  41. pc2[0] = new Participant("qwe", 6.23);
  42. pc2[1] = new Participant("rty", 5.53);
  43. pc2[2] = new Participant("asd", 4.49);
  44. pc2[3] = new Participant("fgh", 4.58);
  45. Down(pc1);
  46. Down(pc2);
  47. Participant[] pc = new Participant[pc1.Length + pc2.Length];
  48. int i = 0, j = 0;
  49. for (int l = 0; l < pc.Length; l++)
  50. {
  51. if (i >= pc1.Length)
  52. {
  53. pc[l] = pc2[j];
  54. j++;
  55. }
  56. else if (j >= pc2.Length)
  57. {
  58. pc[l] = pc1[i];
  59. i++;
  60. }
  61. else if (pc1[i].result < pc2[j].result)
  62. {
  63. pc[l] = pc1[i];
  64. i++;
  65. }
  66. else
  67. {
  68. pc[l] = pc2[j];
  69. j++;
  70. }
  71. }
  72. for (int k = 0; k < pc.Length; k++)
  73. WriteLine("famile is {0}\t" + "result is {1:f2}", pc[k].famile, pc[k].result);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement