Advertisement
Guest User

японцы студенты стипендия

a guest
Dec 18th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.31 KB | None | 0 0
  1. 2-2
  2.  
  3.  
  4. struct S1
  5.     {
  6.         public string fam;
  7.         public double[] x;
  8.         public double sred;
  9.         public S1(string fam1,double [] x1)
  10.         {
  11.             sred = 0;
  12.             fam = fam1;
  13.             x = x1;
  14.             for(int i=0;i<3;i++)
  15.             { sred += x[i]; }
  16.             sred = sred / 3;
  17.         }
  18.     }
  19.     class Program
  20.     {
  21.         static void Main(string[] args)
  22.         {
  23.             int i, j, k, m;
  24.             const int n = 5;
  25.             S1 b;
  26.             S1[] a = new S1[n];
  27.             a[0] = new S1("QWERT", new double[] { 3, 3, 3 });
  28.             a[1] = new S1("QWERT", new double[] { 1, 2, 3 });
  29.             a[2] = new S1("QWERT", new double[] { 1, 2, 3 });
  30.             a[3] = new S1("QWERTy", new double[] { 5, 5, 3 });
  31.             a[4] = new S1("QWERT", new double[] { 1, 2, 3 });      
  32.             for(i=0;i<n;i++)
  33.             {
  34.                 for(j=i;j<n;j++)
  35.                 {
  36.                     if (a[i].sred < a[j].sred) { b = a[i];a[i] = a[j];a[j] = b; }
  37.                 }
  38.  
  39.             }
  40.             for(i=0;i<n;i++)
  41.             {
  42.                 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); }
  43.             }
  44.  
  45.  
  46.         }
  47.     }
  48.  
  49.  
  50.  
  51. 2-5
  52.  
  53.  
  54.  
  55.     struct S1
  56.     {
  57.         public string fam;
  58.         public int[] x;
  59.         public double res;
  60.         public S1(string fam1,int [] x1,int dlin1)
  61.         {
  62.             res = 0;
  63.             fam = fam1;
  64.             x = x1;
  65.             int k;
  66.             for(int i=0;i<5;i++)
  67.             {
  68.                 for(int j=i;i<5;i++)
  69.                 {
  70.                     if (x[i] < x[j]) { k = x[i];x[i] = x[j];x[j] = k; }
  71.                 }
  72.             }
  73.             for(int i=1;i<4;i++)
  74.             {
  75.                 res += x[i];
  76.             }
  77.             res = res / 3;
  78.             res = res + 60 + 2*(dlin1 - 120);
  79.         }
  80.     }
  81.     class Program
  82.     {
  83.         static void Main(string[] args)
  84.         {
  85.             int i, j, k, m;
  86.             const int n = 5;
  87.             S1 b;
  88.             S1[] a = new S1[n];
  89.             a[0] = new S1("QWERT", new int[] { 3, 3, 3,3,3 },120);
  90.             a[1] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 150);
  91.             a[2] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);
  92.             a[3] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);
  93.             a[4] = new S1("QWERT", new int[] { 3, 3, 3, 3, 3 }, 120);      
  94.             for(i=0;i<n;i++)
  95.             {
  96.                 for(j=i;j<n;j++)
  97.                 {
  98.                     if (a[i].res < a[j].res) { b = a[i];a[i] = a[j];a[j] = b; }
  99.                 }
  100.  
  101.             }
  102.             for(i=0;i<n;i++)
  103.             {
  104.                 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); }
  105.             }
  106.  
  107.  
  108.         }
  109.     }
  110.  
  111.  
  112.  
  113.  
  114. 3-1
  115.  
  116.  
  117.    
  118.     class Program
  119.     {
  120.         struct group
  121.         {
  122.             public student[] a;
  123.             public double rez;
  124.             public int n;
  125.             public group(int n1, student[] a1)
  126.             {
  127.                 n = n1;
  128.                 a = a1;
  129.                 rez = 0;
  130.                 for (int i = 0; i < 3; ++i)
  131.                 {
  132.                     rez += a[i].sred;
  133.                 }
  134.                 rez /= 3;
  135.             }
  136.  
  137.         }
  138.         struct student
  139.         {
  140.             public string fam;
  141.             public double[] x;
  142.             public double sred;
  143.             public student(double[] x1, string fam1)
  144.             {
  145.                 sred = 0;
  146.                 fam = fam1;
  147.                 x = x1;
  148.                 double k;
  149.                 for (int i = 0; i < 5; ++i)
  150.                 {
  151.                     sred += x[i];
  152.                 }
  153.                 sred /= 5;
  154.             }
  155.  
  156.         }
  157.         static void Main(string[] args)
  158.         {
  159.  
  160.             int i, j, k;
  161.             group p;
  162.             group[] b = new group[3];
  163.             b[0] = new group(1, new student[] { new student(new double[] { 5, 2, 3, 4, 5 }, "QWERTYYYYYYYY"),
  164.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
  165.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
  166.             b[1] = new group(2, new student[] { new student(new double[] { 5, 6, 3, 4, 5 }, "QWERTYYYYY"),
  167.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
  168.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
  169.             b[2] = new group(3, new student[] { new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
  170.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY"),
  171.             new student(new double[] { 1, 2, 3, 4, 5 }, "QWERTY")});
  172.             for (i = 0; i < 3; i++)
  173.             {
  174.                 for (j = i; j < 3; j++)
  175.                 {
  176.                     if (b[i].rez < b[j].rez) { p = b[i]; b[i] = b[j]; b[j] = p; }
  177.                 }
  178.             }
  179.             for (i = 0; i < 3; i++)
  180.             {
  181.                 Console.WriteLine("Группа {0}", b[i].n);
  182.                 for (j = 0; j < 3; j++)
  183.                 {
  184.                     Console.WriteLine("Фамилия {0}\t" + "Итоговый Балл {1,4:f2}", b[i].a[j].fam, b[i].a[j].sred);
  185.                 }
  186.                 Console.WriteLine();
  187.             }
  188.         }
  189.     }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. {
  200.     struct num
  201.     {
  202.         public string s;
  203.         public int kol;
  204.         public num( int kol1,string s1)
  205.         {
  206.             s = s1;
  207.             kol = kol1;
  208.         }
  209.     }
  210.     class Program
  211.     {
  212.         static void vivod(num [] a,int k,int s)
  213.         {
  214.             double per;
  215.             for (int i = 0; i < k; i++)
  216.             {
  217.                 if (a[i].s != "-")
  218.                 {
  219.                     per = a[i].kol / s;
  220.                     Console.WriteLine("{0} {1,4:f4}", a[i].s, per);
  221.                 }
  222.             }
  223.         }
  224.         static void Main(string[] args)
  225.         {
  226.             const int n = 5;
  227.             num[] a = new num[3 * n];
  228.             a[0].s = "qwert";
  229.             a[1].s = "123";
  230.             a[2].s = "pol";
  231.             a[3].s = "-";
  232.             a[4].s = "123";
  233.             a[5].s = "poli";
  234.             a[6].s = "qwer";
  235.             a[7].s = "124";
  236.             a[8].s = "polia";
  237.             a[9].s = "-";
  238.             a[10].s = "-";
  239.             a[11].s = "-";
  240.             a[12].s = "-";
  241.             a[13].s = "-";
  242.             a[14].s = "pol";
  243.  
  244.             num[] animal = new num[n];
  245.             num[] ch = new num[n];
  246.             num[] pred = new num[n];
  247.             bool f;
  248.             int k1 = 0, k2 = 0, k3 = 0;
  249.             int su1 = 0, su2 = 0, su3 = 0;
  250.             for (int i = 0; i < 3 * n; i += 3)
  251.             {
  252.                 string c1 = a[i].s;
  253.                 if (c1 != "-") { su1 += 1; }
  254.                 f = true;
  255.                 for (int j = 0; j < k1; ++j)
  256.                 {
  257.                     if (c1 == animal[j].s)
  258.                     {
  259.                         animal[j].kol += 1;
  260.                         f = false;
  261.                     }
  262.                 }
  263.                 if (f == true)
  264.                 {
  265.                     animal[k1].s = c1;
  266.                     animal[k1].kol = 1;
  267.                     k1++;
  268.                 }
  269.                 string c2 = a[i + 1].s;
  270.                 if (c2 != "-") { su2 += 1; }
  271.                 f = true;
  272.                 for (int j = 0; j < k2; ++j)
  273.                 {
  274.                     if (c2 == ch[j].s)
  275.                     {
  276.                         ch[j].kol += 1;
  277.                         f = false;
  278.                     }
  279.                 }
  280.                 if (f == true)
  281.                 {
  282.                     ch[k2].s = c2;
  283.                     ch[k2].kol = 1;
  284.                     k2++;
  285.                 }
  286.                 string c3 = a[i + 2].s;
  287.                 if (c3 != "-") { su3 += 1; }
  288.                 f = true;
  289.                 for (int j = 0; j < k3; ++j)
  290.                 {
  291.                     if (c3 == pred[j].s)
  292.                     {
  293.                         pred[j].kol += 1;
  294.                         f = false;
  295.                     }
  296.                 }
  297.                 if (f == true)
  298.                 {
  299.                     pred[k3].s = c3;
  300.                     pred[k3].kol = 1;
  301.                     k3++;
  302.                 }
  303.  
  304.  
  305.             }
  306.             for (int i = 0; i < n; ++i)
  307.             {
  308.                 for (int j = i; j < n; ++j)
  309.                 {
  310.                     if (animal[j].kol > animal[i].kol)
  311.                     {
  312.                         num p = animal[j];
  313.                         animal[j] = animal[i];
  314.                         animal[i] = p;
  315.                     }
  316.                     if (ch[j].kol > ch[i].kol)
  317.                     {
  318.                         num q = ch[j];
  319.                         ch[j] = ch[i];
  320.                         ch[i] = q;
  321.                     }
  322.                     if (pred[j].kol > pred[i].kol)
  323.                     {
  324.                         num w = pred[j];
  325.                         pred[j] = pred[i];
  326.                         pred[i] = w;
  327.                     }
  328.                 }
  329.             }
  330.             vivod(animal, k1, su1);
  331.             vivod(ch, k2, su2);
  332.             vivod(pred, k3, su3);
  333.  
  334.         }
  335.     }
  336. }
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348. using System;
  349. using System.Collections.Generic;
  350. using System.Linq;
  351. using System.Text;
  352. using System.Threading.Tasks;
  353.  
  354. namespace ConsoleApp1
  355. {
  356. public class Student
  357. {
  358.  
  359. public Student(string surname, int[] marks)
  360. {
  361. this.surname = surname;
  362. this.marks = marks;
  363.  
  364. int count = 0;
  365. for (int i = 0; i < 5; i++)
  366. {
  367. avrg += marks[i];
  368. count++;
  369. }
  370. avrg /= count;
  371. }
  372.  
  373.  
  374. public string surname;
  375. public int[] marks;
  376. public double avrg;
  377.  
  378. }
  379.  
  380. public class StudentWithMoney : Student
  381. {
  382.  
  383.  
  384. public StudentWithMoney(string surname, int[] marks) : base(surname, marks)
  385. {
  386. this.surname = surname;
  387. this.marks = marks;
  388. int count = 0;
  389. int min = marks[0];
  390. for (int i = 0; i < 5; i++)
  391. {
  392. if (marks[i] < min)
  393. {
  394. min = marks[i];
  395. }
  396. avrg += marks[i];
  397. count++;
  398. }
  399. avrg /= count;
  400.  
  401. if (min < 4)
  402. {
  403. money = 0;
  404. }
  405. else
  406. {
  407. if (min == 4)
  408. {
  409. money = 1500;
  410. }
  411. else
  412. {
  413. money = 3000;
  414. }
  415. }
  416. }
  417.  
  418. public int money;
  419. }
  420.  
  421.  
  422.  
  423.  
  424. class Program
  425. {
  426.  
  427.  
  428. static void sort(StudentWithMoney[] groups)
  429. {
  430. for (int i = 0; i < 3; i++)
  431. {
  432. for (int j = 0; j < 2; j++)
  433. {
  434. if ((groups[j].avrg) < (groups[j + 1].avrg))
  435. {
  436. StudentWithMoney dop = groups[j];
  437. groups[j] = groups[j + 1];
  438. groups[j + 1] = dop;
  439. }
  440. }
  441. }
  442. }
  443.  
  444. static StudentWithMoney[] concatination(ref StudentWithMoney[] group1, ref StudentWithMoney[] group2, int n, int m)
  445. {
  446. StudentWithMoney[] group = new StudentWithMoney[n + m];
  447.  
  448. for (int i = 0; i < n; i++)
  449. {
  450. group[i] = group1[i];
  451. }
  452. int j = n;
  453. for (int k = 0; k < m; k++)
  454. {
  455. group[j] = group2[k];
  456. j++;
  457. }
  458.  
  459. return group;
  460.  
  461. }
  462.  
  463. static void print(StudentWithMoney[] groups, int n, int m)
  464. {
  465. Console.Write("Имя " + " 1 оценка " + " 2 оценка" + " 3 оценка" + " 4 оценка" + " 5 оценка" + " Средний балл" + " Стипендия");
  466. Console.WriteLine();
  467.  
  468. for (int i = 0; i < n + m; i++)
  469. {
  470. 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);
  471. Console.WriteLine();
  472. }
  473. }
  474.  
  475.  
  476. static void Main(string[] args)
  477. {
  478. StudentWithMoney[] groups1 = new StudentWithMoney[3];
  479. groups1[0] = new StudentWithMoney("Ivanov", new int[] { 2, 3, 5, 5, 5 });
  480. groups1[1] = new StudentWithMoney("Petrov", new int[] { 4, 4, 4, 5, 5 });
  481. groups1[2] = new StudentWithMoney("Sidorov", new int[] { 5, 5, 5, 5, 5 });
  482.  
  483. StudentWithMoney[] groups2 = new StudentWithMoney[3];
  484. groups2[0] = new StudentWithMoney("Ivanov", new int[] { 4, 4, 5, 5, 5 });
  485. groups2[1] = new StudentWithMoney("Petrov", new int[] { 4, 4, 3, 5, 5 });
  486. groups2[2] = new StudentWithMoney("Sidorov", new int[] { 2, 5, 5, 5, 5 });
  487.  
  488.  
  489. sort(groups1);
  490. sort(groups2);
  491. int n = 3, m = 3;
  492. StudentWithMoney[] groups = concatination(ref groups1, ref groups2, n, m);
  493.  
  494. Console.WriteLine("Таблица результатов:");
  495. print(groups, n, m);
  496.  
  497.  
  498. Console.ReadKey();
  499. }
  500. }
  501. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement