Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace C
- {
- class Program
- {
- class bus
- {
- string mark;
- int cout_pas;
- double speed_max;
- double cost;
- public void input(string m, int c, double s, double co)
- {
- mark = m;
- cout_pas = c;
- speed_max = s;
- cost = co;
- }
- public void input()
- {
- Console.Write("Марка:");
- mark = Console.ReadLine();
- Console.Write("Количество пассажиров:");
- cout_pas = Convert.ToInt32(Console.ReadLine());
- Console.Write("Максимальная скорость:");
- speed_max = Convert.ToDouble(Console.ReadLine());
- Console.Write("Цена:");
- cost = Convert.ToDouble(Console.ReadLine());
- }
- public void output()
- {
- Console.WriteLine("Марка:{0} кол.мес:{1} мак.скор:{2} цена:{3}", mark, cout_pas, speed_max, cost);
- }
- public void output (int b)
- {
- Console.WriteLine("Марка[{4}]:{0} кол.мес[{4}]:{1} мак.скор[{4}]:{2} цена[{4}]:{3}", mark, cout_pas, speed_max, cost, b);
- }
- public static bus operator +(bus a, bus b)
- {
- bus v = new bus();
- v.mark = a.mark + b.mark;
- v.cout_pas = a.cout_pas + b.cout_pas;
- v.speed_max = a.speed_max + b.speed_max;
- v.cost = a.cost + b.cost;
- return v;
- }
- public static bus operator +(bus a)
- {
- bus v = new bus();
- a.mark += a.mark;
- a.cout_pas += a.cout_pas;
- a.speed_max += a.speed_max;
- a.cost += a.cost;
- return a;
- }
- public static bool operator ==(bus a, bus b)
- {
- if (a.mark == b.mark && a.cout_pas == b.cout_pas && a.speed_max == b.speed_max && a.cost == b.cost)
- return true;
- else
- return false;
- }
- public static bool operator !=(bus a, bus b)
- {
- if (a.mark != b.mark && a.cout_pas != b.cout_pas && a.speed_max != b.speed_max && a.cost != b.cost)
- return true;
- else
- return false;
- }
- public static bool operator >=(bus a, bus b)
- {
- if (a.cout_pas >= b.cout_pas && a.speed_max >= b.speed_max && a.cost >= b.cost)
- return true;
- else
- return false;
- }
- public static bool operator <=(bus a, bus b)
- {
- if (a.cout_pas <= b.cout_pas && a.speed_max <= b.speed_max && a.cost <= b.cost)
- return true;
- else
- return false;
- }
- }
- static void Main(string[] args)
- {
- string[] bus_mark = { "Lolol", "Tesla", "Prost", "Supra", "Apach", "Mazda", "Audig" };
- int[] bus_count_per = { 100, 200, 300, 35, 40, 50, 10, 20, 15, 5 };
- double[] bus_speed_max = { 105.6, 120, 320, 650, 152.7, 250, 175.4, 152.3 };
- double[] bus_cost = { 3000, 2000.50, 356.25, 2541, 150.60, 20863.58 };
- int n, j = 0;
- Console.Write("Количестов элементов:");
- n = Convert.ToInt32(Console.ReadLine());
- Random r = new Random();
- bus[] b = new bus[n];
- bus g = new bus();
- for (int i = 0; i < n; i++)
- {
- b[i] = new bus();
- b[i].input(bus_mark[r.Next(0, bus_cost.Length)], bus_count_per[r.Next(0, bus_count_per.Length)], bus_speed_max[r.Next(0, bus_speed_max.Length)], bus_cost[r.Next(0, bus_cost.Length)]);
- }
- for (int i = 0; i < n; i++)
- b[i].output(i);
- Console.WriteLine("=============================================================================");
- for (int i = 0; i < n; i++, Console.WriteLine())
- {
- if (i + 1 != n)
- {
- if (b[i] >= b[i + 1])
- Console.Write("b[{0}] >= b[{1}]", i, i + 1);
- else
- Console.Write("b[{0}] <= b[{1}]", i, i + 1);
- if (b[i] == b[i + 1])
- {
- Console.Write(" b[{0}] == b[{1}]", i, i + 1);
- j = i;
- }
- else
- Console.Write(" b[{0}] != b[{1}]", i, i + 1);
- }
- }
- g = b[0] + b[1];
- g.output();
- g += b[0];
- g.output();
- Console.WriteLine("одинаковые значения в {0}", j);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment