Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp2
- {
- struct Sauri : IComparable<Sauri>
- {
- public string name, sur, patr;
- public int year;
- public string pos;
- public int salary;
- public int exp;
- public Sauri(string sur, string name, string patr, int year, string pos, int salary, int exp)
- {
- this.name = name;
- this.sur = sur;
- this.patr = patr;
- this.pos = pos;
- this.year = year;
- this.salary = salary;
- this.exp = exp;
- }
- public void Show()
- {
- Console.WriteLine("* {0} {1} {2}, принят на работу в {3} году, должность - {4}, зарплата - {5} руб, стаж - {6} месяцев", sur, name, patr, year, pos, salary, exp);
- }
- public int CompareTo(Sauri obj) //проводим переопределением метода
- { // CompareTo(T) так, чтобы сравнение элементов
- if ( this.exp == obj.exp ) // типа SPoint проводилось по возрастанию
- { ///расстоянию от точки до начала координат
- return 0;
- }
- else
- {
- if (this.exp > obj.exp)
- {
- return 1;
- }
- else
- {
- return -1;
- }
- }
- }
- }
- class Program
- {
- static public Sauri[] Input()
- {
- using (StreamReader fileIn = new StreamReader(@"C:/Users/belousaa/Documents/in2.txt", Encoding.GetEncoding(1251)))
- {
- int n = int.Parse(fileIn.ReadLine());
- Sauri[] ar = new Sauri[n]; //описание массива структур
- for (int i = 0; i < n; i++)
- {
- string[] text = fileIn.ReadLine().Split(' ');
- ar[i] = new Sauri(text[0], text[1], text[2], int.Parse(text[3]), text[4], int.Parse(text[5]), int.Parse(text[6])); //вызов конструктора структуры
- }
- return ar; //в качестве результата метод возвращает ссылку на массив структур
- }
- }
- static void Print(Sauri[] array, int zar) //выводим данные на экран
- {
- for(int i=0;i<array.Length;i++)
- {
- if (array[i].salary < zar)
- {
- array[i].Show(); //обращается к методу экземпляра структуры
- }
- }
- }
- static void Main(string[] args)
- {
- Sauri[] array = Input();
- Console.WriteLine("Введите пожалуйста порог зарплаты: ");
- int zar = int.Parse(Console.ReadLine());
- Array.Sort(array);
- Print(array,zar);
- }
- }
- }
- /*
- 4
- Белоус Алексей Андреевич 2019 СПД 31000 5
- Ножов Александр Михайлович 2019 СПД 44000 8
- Герцог Александра Сергеевна 2018 Кассир 22500 13
- Алукаев Тимур Александрович 2019 СПД 27000 3
- */
Add Comment
Please, Sign In to add comment