Ejemplo n.º 1
0
        static void task1()
        {
            MeteData        Day5  = new MeteData("23.05.2020", 16, 737);
            MeteData        Day4  = new MeteData("19.05.2020", 19, 730);
            MeteData        Day3  = new MeteData("16.05.2020", 16, 748);
            MeteData        Day1  = new MeteData("21.05.2020", 17, 747);
            MeteData        Day2  = new MeteData("14.05.2020", 14, 740);
            MeteData        Day6  = new MeteData("30.05.2020", 10, 737);
            MeteData        Day7  = new MeteData("11.05.2020", 11, 730);
            MeteData        Day8  = new MeteData("05.05.2020", 34, 707);
            MeteData        Day9  = new MeteData("10.05.2020", 15, 732);
            MeteData        Day10 = new MeteData("01.05.2020", 20, 750);
            List <MeteData> Days  = new List <MeteData>();

            Days.Add(Day1); Days.Add(Day2); Days.Add(Day3); Days.Add(Day4); Days.Add(Day5);
            Days.Add(Day6); Days.Add(Day7); Days.Add(Day8); Days.Add(Day9); Days.Add(Day10);
            MeteData Most = Days[0];
            MeteData Less = Days[0];

            Days[0].sort(Days, out Most, out Less);
            Console.WriteLine("Date      |Temperature | Atmosphere Pressure");
            for (int i = 0; i < Days.Count; i++)
            {
                Console.WriteLine(Days[i].Data + "|" + Days[i].Tempreture + "          |" + Days[i].AtmospherePressure);
            }
            Console.WriteLine("\nThe greatest Atmosphere Pressure");
            Console.WriteLine(Most.Data + "|" + Most.AtmospherePressure);
            Console.WriteLine("The least Atmosphere Pressure");
            Console.WriteLine(Less.Data + "|" + Less.AtmospherePressure);
        }
Ejemplo n.º 2
0
 public void sort(List <MeteData> Days, out MeteData Most, out MeteData Less)
 {
     Most = Days[0];
     Less = Days[0];
     for (int i = 0; i < Days.Count; i++)
     {
         for (int k = 0; k < Days.Count; k++)
         {
             if (Most.AtmospherePressure < Days[k].AtmospherePressure)
             {
                 Most = Days[i];
             }
             if (Less.AtmospherePressure > Days[k].AtmospherePressure)
             {
                 Less = Days[i];
             }
             if (Days[i].AtmospherePressure > Days[k].AtmospherePressure)
             {
                 MeteData temp = Days[k];
                 Days[k] = Days[i];
                 Days[i] = temp;
             }
         }
     }
 }