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 Charp2_1
- {
- public class Person
- {
- public string Name { get; set; }
- public string Surname { get; set; }
- public int Age { get; set; }
- public string Sex { get; set; }
- public Person(string Name,string Surname,int Age,string Sex)
- {
- this.Name = Name;
- this.Surname = Surname;
- this.Age = Age;
- this.Sex = Sex;
- }
- public void Print()
- {
- Console.Write(this.Name + " " + this.Surname + " Возраст : " + this.Age + " Пол : " + this.Sex );
- }
- }
- public class Employee : Person
- {
- string Company { get; set; }
- string Job { get; set; }
- int Moneys { get; set; }
- public Employee(string Name, string Surname, int Age, string Sex, string Company, string Job, int Moneys):base(Name, Surname, Age, Sex)
- {
- this.Company = Company;
- this.Job = Job;
- this.Moneys = Moneys;
- }
- public void Print()
- {
- base.Print();
- Console.WriteLine(" " + this.Company + " " + this.Job + " " + this.Moneys);
- }
- }
- class Program
- {
- static void Main()
- {
- StreamReader f = File.OpenText("input.txt");
- StreamWriter f2 = new StreamWriter("output.txt");
- int n = 2;
- Employee[] a = new Employee[n];
- for (int i = 0; i < n; i++)
- {
- string s = f.ReadLine();
- string[] w = new string[7];
- w[0] = s.Split(' ')[0];
- w[1] = s.Split(' ')[1];
- w[2] = s.Split(' ')[2];
- w[3] = s.Split(' ')[3];
- w[4] = s.Split(' ')[4];
- w[5] = s.Split(' ')[5];
- w[6] = s.Split(' ')[6];
- a[i] = new Employee(w[0], w[1], Convert.ToInt32(w[2]), w[3], w[4], w[5], Convert.ToInt32(w[6]));
- a[i].Print();
- }
- Console.WriteLine("");
- Console.WriteLine("Список Мужчин");
- for (int i = 0; i < n; i++)
- {
- if (a[i].Sex == "М")
- {
- a[i].Print();
- }
- }
- Console.WriteLine("");
- Console.WriteLine("Список Женщин");
- for (int i = 0; i < n; i++)
- {
- if (a[i].Sex == "Ж")
- {
- a[i].Print();
- }
- }
- Console.WriteLine("");
- Console.WriteLine("Люди старше 40 лет");
- for (int i = 0; i < n; i++)
- {
- if (a[i].Age > 40)
- {
- a[i].Print();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment