Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2-2
- struct S1
- {
- public string fam;
- public double[] x;
- public double sred;
- public S1(string fam1,double [] x1)
- {
- sred = 0;
- fam = fam1;
- x = x1;
- for(int i=0;i<3;i++)
- { sred += x[i]; }
- sred = sred / 3;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int i, j, k, m;
- const int n = 5;
- S1 b;
- S1[] a = new S1[n];
- a[0] = new S1("QWERT", new double[] { 3, 3, 3 });
- a[1] = new S1("QWERT", new double[] { 1, 2, 3 });
- a[2] = new S1("QWERT", new double[] { 1, 2, 3 });
- a[3] = new S1("QWERTy", new double[] { 5, 5, 3 });
- a[4] = new S1("QWERT", new double[] { 1, 2, 3 });
- for(i=0;i<n;i++)
- {
- for(j=i;j<n;j++)
- {
- if (a[i].sred < a[j].sred) { b = a[i];a[i] = a[j];a[j] = b; }
- }
- }
- for(i=0;i<n;i++)
- {
- if (a[i].x[0] > 2 && a[i].x[1] > 2 && a[i].x[2] > 2) { Console.WriteLine("Фамилия {0}\t" + "Средний балл {1,4:f2}", a[i].fam, a[i].sred); }
- }
- }
- }
- 2-5
- struct S1
- {
- public string fam;
- public int[] x;
- public double res;
- public S1(string fam1,int [] x1,int dlin1)
- {
- res = 0;
- fam = fam1;
- x = x1;
- int k;
- for(int i=0;i<5;i++)
- {
- for(int j=i;i<5;i++)
- {
- if (x[i] < x[j]) { k = x[i];x[i] = x[j];x[j] = k; }
- }
- }
- for(int i=1;i<4;i++)
- {
- res += x[i];
- }
- res = res / 3;
- res = res + 60 + 2*(dlin1 - 120);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int i, j, k, m;
- const int n = 5;
- S1 b;
- S1[] a = new S1[n];
- a[0] = new S1("QWERT", new int[] { 3, 3, 3,3,3 },120);
- a[1] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 150);
- a[2] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);
- a[3] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);
- a[4] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);
- for(i=0;i<n;i++)
- {
- for(j=i;j<n;j++)
- {
- if (a[i].res < a[j].res) { b = a[i];a[i] = a[j];a[j] = b; }
- }
- }
- for(i=0;i<n;i++)
- {
- if (a[i].x[0] > 2 && a[i].x[1] > 2 && a[i].x[2] > 2) { Console.WriteLine("Фамилия {0}\t" + "Итоговый Балл {1,4:f2}", a[i].fam, a[i].res); }
- }
- }
- }
- 3-1
- class Program
- {
- struct group
- {
- public student[] a;
- public double rez;
- public int n;
- public group(int n1, student[] a1)
- {
- n = n1;
- a = a1;
- rez = 0;
- for (int i = 0; i < 3; ++i)
- {
- rez += a[i].sred;
- }
- rez /= 3;
- }
- }
- struct student
- {
- public string fam;
- public double[] x;
- public double sred;
- public student(double[] x1, string fam1)
- {
- sred = 0;
- fam = fam1;
- x = x1;
- double k;
- for (int i = 0; i < 5; ++i)
- {
- sred += x[i];
- }
- sred /= 5;
- }
- }
- static void Main(string[] args)
- {
- int i, j, k;
- group p;
- group[] b = new group[3];
- b[0] = new group(1, new student[] { new student(new double[] { 5, 2, 3, 4, 5 }, "QWERTYYYYYYYY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
- b[1] = new group(2, new student[] { new student(new double[] { 5, 6, 3, 4, 5 }, "QWERTYYYYY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
- b[2] = new group(3, new student[] { new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
- new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
- for (i = 0; i < 3; i++)
- {
- for (j = i; j < 3; j++)
- {
- if (b[i].rez < b[j].rez) { p = b[i]; b[i] = b[j]; b[j] = p; }
- }
- }
- for (i = 0; i < 3; i++)
- {
- Console.WriteLine("Группа {0}", b[i].n);
- for (j = 0; j < 3; j++)
- {
- Console.WriteLine("Фамилия {0}\t" + "Итоговый Балл {1,4:f2}", b[i].a[j].fam, b[i].a[j].sred);
- }
- Console.WriteLine();
- }
- }
- }
- {
- struct num
- {
- public string s;
- public int kol;
- public num( int kol1,string s1)
- {
- s = s1;
- kol = kol1;
- }
- }
- class Program
- {
- static void vivod(num [] a,int k,int s)
- {
- double per;
- for (int i = 0; i < k; i++)
- {
- if (a[i].s != "-")
- {
- per = a[i].kol / s;
- Console.WriteLine("{0} {1,4:f4}", a[i].s, per);
- }
- }
- }
- static void Main(string[] args)
- {
- const int n = 5;
- num[] a = new num[3 * n];
- a[0].s = "qwert";
- a[1].s = "123";
- a[2].s = "pol";
- a[3].s = "-";
- a[4].s = "123";
- a[5].s = "poli";
- a[6].s = "qwer";
- a[7].s = "124";
- a[8].s = "polia";
- a[9].s = "-";
- a[10].s = "-";
- a[11].s = "-";
- a[12].s = "-";
- a[13].s = "-";
- a[14].s = "pol";
- num[] animal = new num[n];
- num[] ch = new num[n];
- num[] pred = new num[n];
- bool f;
- int k1 = 0, k2 = 0, k3 = 0;
- int su1 = 0, su2 = 0, su3 = 0;
- for (int i = 0; i < 3 * n; i += 3)
- {
- string c1 = a[i].s;
- if (c1 != "-") { su1 += 1; }
- f = true;
- for (int j = 0; j < k1; ++j)
- {
- if (c1 == animal[j].s)
- {
- animal[j].kol += 1;
- f = false;
- }
- }
- if (f == true)
- {
- animal[k1].s = c1;
- animal[k1].kol = 1;
- k1++;
- }
- string c2 = a[i + 1].s;
- if (c2 != "-") { su2 += 1; }
- f = true;
- for (int j = 0; j < k2; ++j)
- {
- if (c2 == ch[j].s)
- {
- ch[j].kol += 1;
- f = false;
- }
- }
- if (f == true)
- {
- ch[k2].s = c2;
- ch[k2].kol = 1;
- k2++;
- }
- string c3 = a[i + 2].s;
- if (c3 != "-") { su3 += 1; }
- f = true;
- for (int j = 0; j < k3; ++j)
- {
- if (c3 == pred[j].s)
- {
- pred[j].kol += 1;
- f = false;
- }
- }
- if (f == true)
- {
- pred[k3].s = c3;
- pred[k3].kol = 1;
- k3++;
- }
- }
- for (int i = 0; i < n; ++i)
- {
- for (int j = i; j < n; ++j)
- {
- if (animal[j].kol > animal[i].kol)
- {
- num p = animal[j];
- animal[j] = animal[i];
- animal[i] = p;
- }
- if (ch[j].kol > ch[i].kol)
- {
- num q = ch[j];
- ch[j] = ch[i];
- ch[i] = q;
- }
- if (pred[j].kol > pred[i].kol)
- {
- num w = pred[j];
- pred[j] = pred[i];
- pred[i] = w;
- }
- }
- }
- vivod(animal, k1, su1);
- vivod(ch, k2, su2);
- vivod(pred, k3, su3);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- public class Student
- {
- public Student(string surname, int[] marks)
- {
- this.surname = surname;
- this.marks = marks;
- int count = 0;
- for (int i = 0; i < 5; i++)
- {
- avrg += marks[i];
- count++;
- }
- avrg /= count;
- }
- public string surname;
- public int[] marks;
- public double avrg;
- }
- public class StudentWithMoney : Student
- {
- public StudentWithMoney(string surname, int[] marks) : base(surname, marks)
- {
- this.surname = surname;
- this.marks = marks;
- int count = 0;
- int min = marks[0];
- for (int i = 0; i < 5; i++)
- {
- if (marks[i] < min)
- {
- min = marks[i];
- }
- avrg += marks[i];
- count++;
- }
- avrg /= count;
- if (min < 4)
- {
- money = 0;
- }
- else
- {
- if (min == 4)
- {
- money = 1500;
- }
- else
- {
- money = 3000;
- }
- }
- }
- public int money;
- }
- class Program
- {
- static void sort(StudentWithMoney[] groups)
- {
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 2; j++)
- {
- if ((groups[j].avrg) < (groups[j + 1].avrg))
- {
- StudentWithMoney dop = groups[j];
- groups[j] = groups[j + 1];
- groups[j + 1] = dop;
- }
- }
- }
- }
- static StudentWithMoney[] concatination(ref StudentWithMoney[] group1, ref StudentWithMoney[] group2, int n, int m)
- {
- StudentWithMoney[] group = new StudentWithMoney[n + m];
- for (int i = 0; i < n; i++)
- {
- group[i] = group1[i];
- }
- int j = n;
- for (int k = 0; k < m; k++)
- {
- group[j] = group2[k];
- j++;
- }
- return group;
- }
- static void print(StudentWithMoney[] groups, int n, int m)
- {
- Console.Write("Имя " + " 1 оценка " + " 2 оценка" + " 3 оценка" + " 4 оценка" + " 5 оценка" + " Средний балл" + " Стипендия");
- Console.WriteLine();
- for (int i = 0; i < n + m; i++)
- {
- Console.Write(groups[i].surname + " " + groups[i].marks[0] + " " + groups[i].marks[1] + " " + groups[i].marks[2] + " " + groups[i].marks[3] + " " + groups[i].marks[4] + " " + groups[i].avrg + " " + groups[i].money);
- Console.WriteLine();
- }
- }
- static void Main(string[] args)
- {
- StudentWithMoney[] groups1 = new StudentWithMoney[3];
- groups1[0] = new StudentWithMoney("Ivanov", new int[] { 2, 3, 5, 5, 5 });
- groups1[1] = new StudentWithMoney("Petrov", new int[] { 4, 4, 4, 5, 5 });
- groups1[2] = new StudentWithMoney("Sidorov", new int[] { 5, 5, 5, 5, 5 });
- StudentWithMoney[] groups2 = new StudentWithMoney[3];
- groups2[0] = new StudentWithMoney("Ivanov", new int[] { 4, 4, 5, 5, 5 });
- groups2[1] = new StudentWithMoney("Petrov", new int[] { 4, 4, 3, 5, 5 });
- groups2[2] = new StudentWithMoney("Sidorov", new int[] { 2, 5, 5, 5, 5 });
- sort(groups1);
- sort(groups2);
- int n = 3, m = 3;
- StudentWithMoney[] groups = concatination(ref groups1, ref groups2, n, m);
- Console.WriteLine("Таблица результатов:");
- print(groups, n, m);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement