Advertisement
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.Text.RegularExpressions;
- using System.IO;
- class MainClass
- {
- struct BagageList : IComparable
- {
- string Name;
- int CountOfThings;
- double Weight;
- public BagageList(string Name, int CountOfThings, double Weight){
- this.Name = Name;
- this.CountOfThings = CountOfThings;
- this.Weight = Weight;
- }
- public bool checkBagage(double weight)
- {
- if (Weight / CountOfThings > weight)
- return true;
- else
- return false;
- }
- public int CompareTo(object obj)
- {
- BagageList person = (BagageList)obj;
- return this.CountOfThings.CompareTo(person.CountOfThings);
- }
- public override string ToString()
- {
- return String.Format("Фамилия: {0}; количество вещей в багаже: {1}; вес багажа: {2}\n", Name, CountOfThings, Weight);
- }
- }
- public static void Main(string[] args)
- {
- using (StreamWriter fileOut = new StreamWriter(@"C:/Users/karpenkoos/desktop/output.txt"))
- {
- using (StreamReader fileIn = new StreamReader(@"C:/Users/karpenkoos/desktop/input.txt"))
- {
- var a = fileIn.ReadToEnd().Split('\n');
- BagageList[] c = new BagageList[a.Length];
- for (int i = 0; i < a.Length; ++i)
- {
- string[] temp = a[i].Split(' ');
- c[i] = new BagageList(temp[0], int.Parse(temp[1]), double.Parse(temp[2]));
- }
- double weight = 6;
- var answer = c.Where(x => x.checkBagage(weight)).OrderBy(x => x);
- foreach (var v in answer)
- fileOut.WriteLine(v);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement