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;
- namespace classlab8
- {
- class student_group
- {
- main check = new main();
- public string[,] Data;
- int length;
- private void print(int index)
- {
- for (int i = 0; i < 4; i++)
- {
- Console.Write("{0} ",Data[index, i]);
- }
- }
- public student_group(int size)
- {
- Data = new string[size, 4];
- length = size;
- }
- public void data(string name)
- {
- bool is_exist = false;
- for (int i = 0; i < length; i++)
- {
- if (name == Data[i, 0] || name == Data[i,1])
- {
- print(i);
- is_exist = true;
- }
- }
- if (is_exist == false) Console.WriteLine("Записей не найдено!");
- }
- public string this[int i]
- {
- get
- {
- string temp = "";
- if (i >= 0 && i < length) { return temp; }
- else { return "Noname"; }
- }
- set
- {
- if (i >= 0 && i < length)
- {
- string[] mas = value.Split(new char[] {' ','\n','\r','\t', '.'});
- Data[i, 0] = mas[0];
- Data[i, 1] = mas[1];
- Data[i, 2] = Convert.ToString(main.longread(mas[2]));
- Data[i, 3] = Convert.ToString(main.read(mas[3]))+ "." + Convert.ToString(main.read(mas[4])) + "."+ Convert.ToString(main.read(mas[5]));
- }
- }
- }
- }
- class main
- {
- static void Main(string[] args)
- {
- int length;
- length = read(Console.ReadLine());
- student_group create = new student_group(length);
- for (int i = 0; i < length; i++)
- {
- create[i] = Console.ReadLine();
- }
- Console.WriteLine("Введите позицию для поиска:\n1: Фамилия(Имя)");
- int switch_on = read(Console.ReadLine());
- switch (switch_on)
- {
- case 1:Console.WriteLine("Введите фамилию или имя для поиска:");
- create.data(Console.ReadLine()); break;
- case 2: Console.WriteLine("Введите номер телефона:");
- create.data(Convert.ToString(read(Console.ReadLine()))); break;
- case 3: Console.WriteLine("Введите дату рождения для поиска:");
- create.data(Console.ReadLine()); break;
- }
- Console.ReadKey();
- }
- public static bool check(string s)
- {
- long tmp;
- if (long.TryParse(s,out tmp)) return true;
- else return false;
- }
- public static int read(string stream)
- {
- while (!check(stream))
- {
- Console.WriteLine("Введите число!");
- stream = Console.ReadLine();
- }
- return Convert.ToInt16(stream);
- }
- public static long longread(string stream)
- {
- while (!check(stream))
- {
- Console.WriteLine("Введите число!");
- stream = Console.ReadLine();
- }
- return Convert.ToInt64(stream);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement