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 Tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Здравствуйте, что вы хотите сделать?");
- string[] name = { "Иванов", "Петров", "Сидоров" };
- string[] position = { "Менеджер", "Завхоз", "Большая насяльника" };
- Console.WriteLine("1 - добавить досье.");
- Console.WriteLine("2 - вывести все досье.");
- Console.WriteLine("3 - удалить досье.");
- Console.WriteLine("4 - найти работника по фамилии.");
- Console.WriteLine("5 - выход.");
- while (true)
- {
- int userInput = Convert.ToInt32(Console.ReadLine());
- if (userInput == 1)
- {
- Console.WriteLine("Введите фамилию: ");
- Array.Resize(ref name, name.Length + 1);
- string newName = Console.ReadLine();
- name[name.Length - 1] = newName;
- Console.WriteLine("Введите должность: ");
- Array.Resize(ref position, position.Length + 1);
- string newPosition = Console.ReadLine();
- position[position.Length - 1] = newPosition;
- }
- else if (userInput == 2)
- {
- for (int i = 0; i < name.Length; i++)
- {
- Console.Write(i + 1 + " ");
- Console.Write(name[i] + "-");
- Console.Write(position[i] + ". ");
- }
- Console.WriteLine("");
- }
- else if (userInput == 3)
- {
- Console.WriteLine("Введите порядковый номер удаляемого досье.");
- int deleteDossier = Convert.ToInt32(Console.ReadLine());
- string[] newName = new string[name.Length - 1];
- for (int i = 0; i < name.Length; i++)
- {
- if (i < (deleteDossier - 1))
- {
- newName[i] = name[i];
- }
- else if (i > (deleteDossier - 1))
- {
- newName[i - 1] = name[i];
- }
- }
- name = newName;
- string[] newPosition = new string[position.Length - 1];
- for (int j = 0; j < position.Length; j++)
- {
- if (j < (deleteDossier))
- {
- newPosition[j] = position[j];
- }
- else if (j > (deleteDossier - 1))
- {
- newPosition[j - 1] = position[j];
- }
- }
- position = newPosition;
- }
- else if (userInput == 4)
- {
- Console.WriteLine("Введите фамилию");
- string secondName = Console.ReadLine();
- for (int i = 0; i < name.Length; i++)
- {
- if (secondName.ToLower() == name[i].ToLower())
- {
- Console.WriteLine(i + 1 + position[i]);
- break;
- }
- }
- Console.WriteLine("Такого работника нет!!!");
- }
- else if (userInput == 5)
- {
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement