Example #1
0
        static Sstudent A(string fio, byte math, byte phys)
        {
            Sstudent x = new Sstudent();

            x.fio  = fio;
            x.math = math;
            x.phys = phys;

            return(x);
        }
Example #2
0
        static void Main(string[] args)
        {
            string fio;
            byte   math, phys;

            Sstudent[] x = new Sstudent[10];
            while (true)
            {
                Console.Clear();
                Console.WriteLine("1.Add\n2.Print\n3.Win\n4.Lose\n0.Exit");
                int z = int.Parse(Console.ReadLine());
                switch (z)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine("fio");
                    fio = Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine("math");
                    math = byte.Parse(Console.ReadLine());
                    Console.Clear();
                    Console.WriteLine("phys");
                    phys = byte.Parse(Console.ReadLine());

                    for (int i = 0; i < 10; i++)
                    {
                        if (x[i].math == 0)
                        {
                            x[i] = A(fio, math, phys);
                            break;
                        }
                    }
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine("fio\tmath\tphys");
                    for (int i = 0; i < 10; i++)
                    {
                        if (x[i].fio != null)
                        {
                            Console.WriteLine("{0}\t{1}\t{2}", x[i].fio, x[i].math, x[i].phys);
                        }
                        else
                        {
                            break;
                        }
                    }
                    Console.ReadKey();
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine("fio\tmath\tphys");
                    for (int i = 0; i < 10; i++)
                    {
                        if (x[i].math == 5 && x[i].phys == 5)
                        {
                            Console.WriteLine("{0}\t{1}\t{2}", x[i].fio, x[i].math, x[i].phys);
                        }
                    }
                    Console.ReadKey();
                    break;

                case 4:
                    Console.Clear();
                    Console.WriteLine("fio\tmath\tphys");
                    for (int i = 0; i < 10; i++)
                    {
                        if (x[i].math == 2 || x[i].phys == 2)
                        {
                            Console.WriteLine("{0}\t{1}\t{2}", x[i].fio, x[i].math, x[i].phys);
                        }
                    }
                    Console.ReadKey();
                    break;

                case 0:
                    break;
                }
            }
        }
Example #3
0
        static void Struc()
        {
            Sstudent[] students = new Sstudent[10];
            //Inpstud(ref students[i].fio, ref students[i].performance1, ref students[i].performance2);

            int i = 0;
            int j = 0;

            do

            {
up1:
                Console.WriteLine("Вы хотите добавить студента? (Вы можите добавить ещё {0} студентов)", (10 - i));
                Console.WriteLine("1 - да | 0 - нет");

                ConsoleKeyInfo a;
                a = Console.ReadKey(false);
                switch (a.KeyChar.ToString())
                {
                case "1":
                    Inpstud(ref students[i].fio, ref students[i].performance1);
                    j = i + 1;
                    break;

                case "0":
                    i = 10;

                    break;

                default:
                    goto up1;
                }
                i++;
            } while (i < 10);
up2:
            Console.WriteLine("Желаете увидеть список студентов?");
            Console.WriteLine("2 - показать только лучшего | 1 - показать всех | 0 - нет");
            ConsoleKeyInfo cl;

            cl = Console.ReadKey(false);
            switch (cl.KeyChar.ToString())
            {
            case "2":
                int b = 0;
                for (int m = 0; m != j; m++)
                {
                    if (students[m].performance1 > b)
                    {
                        b = m;
                    }
                }
                Outstud(students[b].fio, students[b].performance1);
                Console.ReadKey();
                break;

            case "1":
                for (int m = 0; m != j; m++)
                {
                    Outstud(students[m].fio, students[m].performance1);
                }
                Console.ReadKey();
                break;

            case "0":
                break;

            default:
                goto up2;
            }
        }