Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Participant
- {
- public string famile;
- public double result;
- public Participant(string famile, double result)
- {
- this.famile = famile;
- this.result = result;
- }
- }
- class Program
- {
- static void Down(Participant[] x)
- {
- for (int i = 0; i < x.Length - 1; i++)
- {
- double xmin = x[i].result;
- int imin = i;
- for (int j = i + 1; j < x.Length; j++)
- {
- if (x[j].result < xmin)
- {
- xmin = x[j].result;
- imin = j;
- }
- }
- Participant temp;
- temp = x[imin];
- x[imin] = x[i];
- x[i] = temp;
- }
- }
- static void Main(string[] args)
- {
- Participant[] pc1 = new Participant[4];
- pc1[0] = new Participant("pukin", 5.48);
- pc1[1] = new Participant("vasin", 6.02);
- pc1[2] = new Participant("putin", 5.15);
- pc1[3] = new Participant("adolf", 4.44);
- Participant[] pc2 = new Participant[4];
- pc2[0] = new Participant("qwe", 6.23);
- pc2[1] = new Participant("rty", 5.53);
- pc2[2] = new Participant("asd", 4.49);
- pc2[3] = new Participant("fgh", 4.58);
- Down(pc1);
- Down(pc2);
- Participant[] pc = new Participant[pc1.Length + pc2.Length];
- int i = 0, j = 0;
- for (int l = 0; l < pc.Length; l++)
- {
- if (i >= pc1.Length)
- {
- pc[l] = pc2[j];
- j++;
- }
- else if (j >= pc2.Length)
- {
- pc[l] = pc1[i];
- i++;
- }
- else if (pc1[i].result < pc2[j].result)
- {
- pc[l] = pc1[i];
- i++;
- }
- else
- {
- pc[l] = pc2[j];
- j++;
- }
- }
- for (int k = 0; k < pc.Length; k++)
- WriteLine("famile is {0}\t" + "result is {1:f2}", pc[k].famile, pc[k].result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement