Advertisement
Sephinroth

prac 16

Dec 8th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.IO;
  7.  
  8. namespace ConsoleApplication2
  9. {
  10.     struct SStudent
  11.     {
  12.         public string name;
  13.         public int number, math, eng, philosophy;
  14.         public SStudent (string name, int number, int math, int eng, int philosophy)
  15.         {
  16.             this.name = name;
  17.             this.number = number;
  18.             this.math = math;
  19.             this.eng = eng;
  20.             this.philosophy = philosophy;
  21.         }
  22.        
  23.         public void Show()
  24.         {
  25.             Console.WriteLine("{0}; {1};\n\tматанализ: {2}\n\tангл.яз: {3}\n\tфилософия: {4}", name, number, math, eng, philosophy);
  26.         }
  27.         public bool Check()
  28.         {
  29.             if (math < 3 || eng <3 || philosophy <3)
  30.                 return false; else return true;
  31.         }
  32.     }
  33.    
  34.     class Program
  35.     {
  36.         static void Main(string[] args)
  37.         {
  38.             using (StreamReader input = new StreamReader("e:/practice/input.txt", Encoding.GetEncoding(1251)))
  39.             {
  40.                 int n = int.Parse(input.ReadLine());
  41.                 SStudent [] array = new SStudent[n];
  42.                 for (int i = 0; i < n; i++)
  43.                 {
  44.                     string [] tmp = input.ReadLine().Split(',');
  45.                     array[i].name = tmp[0];
  46.                     array[i].number = int.Parse(tmp[1]);
  47.                     array[i].math = int.Parse(tmp[2]);
  48.                     array[i].eng = int.Parse(tmp[3]);
  49.                     array[i].philosophy = int.Parse(tmp[4]);
  50.                 }
  51.                 using (StreamWriter output = new StreamWriter("e:/practice/output.txt", false))
  52.                 {
  53.                     var Survivalists = array.Where(x => x.Check()).OrderBy(x => x.number);
  54.                     foreach (var x in Survivalists)
  55.                         output.WriteLine("{0}; {1};\n\tматанализ: {2}\n\tангл.яз: {3}\n\tфилософия: {4}", x.name, x.number, x.math, x.eng, x.philosophy);
  56.                 }
  57.             }
  58.                
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement