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 Govno_v2
- {
- class Program
- {
- static string[] names = new string[0];
- static string[] posts = new string[0];
- static void Main(string[] args)
- {
- while (true)
- {
- Console.WriteLine("Список команд: 1-Добавить кадр, 2-Удалить кадр , 3-Поиск , 4-Показать всех ,5-Выход.");
- string a = Console.ReadLine();
- if (a == "1")
- {
- add();
- }
- else if (a == "4")
- {
- for (int i = 0; i < names.Length; i++)
- {
- Console.WriteLine("№ " + (i + 1) + names[i] + " - " + posts[i]);
- }
- }
- else if (a == "5")
- {
- break;
- }
- else if (a == "2")
- {
- del();
- }
- else if (a == "3")
- {
- search();
- }
- }
- }
- static void add()
- {
- Console.WriteLine("Введите имя: ");
- Array.Resize(ref names, names.Length + 1);
- int i = names.Length - 1;
- names[i] = Console.ReadLine();
- Console.WriteLine("Введите должность: ");
- Array.Resize(ref posts, posts.Length + 1);
- i = posts.Length - 1;
- posts[i] = Console.ReadLine();
- }
- static void del()
- {
- Console.WriteLine("Введите номер кадра который хотите удалить");
- int num = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < names.Length && num < names.Length; i++)
- names[num - 1] = names[num];
- posts[num - 1] = posts[num++];
- Array.Resize(ref names, names.Length - 1);
- Array.Resize(ref posts, posts.Length - 1);
- }
- static void search()
- {
- Console.WriteLine("Поиск по имени(1) или по должности(2)?");
- int gg = Convert.ToInt32(Console.ReadLine());
- if (gg == 1)
- {
- Console.WriteLine("Введите имя");
- string searchname = Console.ReadLine();
- for (int i = 0; i < names.Length; i++)
- {
- if (searchname == names[i])
- {
- Console.WriteLine("№ " + (i+1) + " " + names[i] + " - " + posts[i]);
- }
- }
- Console.WriteLine();
- Console.WriteLine("больше ничего не найдено.");
- }
- else if (gg == 2)
- {
- Console.WriteLine("Введите должность");
- string searchpost = Console.ReadLine();
- for (int i = 0; i < names.Length; i++)
- {
- if (searchpost == posts[i])
- {
- Console.WriteLine("№ " + (i + 1) + " " + names[i] + " - " + posts[i]);
- }
- }
- Console.WriteLine();
- Console.WriteLine("больше ничего не найдено.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement