Удалить из списка все повторные записи, проверяя Ф.И.О. и домашний адрес - C#

Узнай цену своей работы

Формулировка задачи:

В case 3: удалить из списка все повторные записи, проверяя Ф.И.О. и домашний адрес. Вот рабочая программа.
Листинг программы
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Magaz[] Pokupat = new Magaz[] { };
  14. string output;
  15. int ID;
  16. string FIO;
  17. string Adress;
  18. string Data;
  19. bool go = true;
  20. while (go)
  21. {
  22. Console.WriteLine(" МЕНЮ \n 1. Ввод покупателей\n 2. Вывести таблицу Покупателей\n 3. Вывести измененную таблицу\n 0. Выход");
  23. Console.Write("\n Выберите пункт -> ");
  24. int N = 0;
  25. int sw = int.Parse(Console.ReadLine());
  26. switch (sw)
  27. {
  28. case 1:
  29. {
  30. Console.Clear();
  31. StreamWriter dataOut;
  32. dataOut = new StreamWriter("F:\\10.txt");
  33. Console.Write("Количество покупателей -> ");
  34. N = Convert.ToInt32(Console.ReadLine());
  35. for (int i = 0; i < N; i++)
  36. {
  37. Console.Write("Введите ID -> ");
  38. ID = Convert.ToInt32(Console.ReadLine());
  39. dataOut.WriteLine(Convert.ToString(ID));
  40. Console.Write("\nВведите ФИО -> ");
  41. FIO = Console.ReadLine();
  42. dataOut.WriteLine(FIO);
  43. Console.Write("Введите Адрес-> ");
  44. Adress = Console.ReadLine();
  45. dataOut.WriteLine(Adress);
  46. Console.Write("Введите дату-> ");
  47. Data = Console.ReadLine();
  48. dataOut.WriteLine(Data);
  49. }
  50. dataOut.Close();
  51. Console.Clear();
  52. break;
  53. }
  54. case 2:
  55. {
  56. Console.Clear();
  57. StreamReader dataIn = new StreamReader("F:\\10.txt");
  58. Console.WriteLine(" ID FIO Адрес Дата\n");
  59. while (dataIn.EndOfStream != true)
  60. {
  61. int id = Convert.ToInt32(dataIn.ReadLine());
  62. string fio = dataIn.ReadLine();
  63. string adres = dataIn.ReadLine();
  64. string dat = dataIn.ReadLine();
  65. output = String.Format("{0,-2} {1,-15} {2,-8} {3,-8}", id, fio, adres, dat);
  66. Console.WriteLine(output);
  67. }
  68. dataIn.Close();
  69. Console.ReadKey();
  70. Console.Clear();
  71. break;
  72. }
  73. case 3:
  74. {
  75. Console.Clear();
  76. StreamReader dataIn = new StreamReader("F:\\10.txt");
  77. int count = 0;
  78. Console.WriteLine(" ID FIO Адрес Дата\n");
  79. while (dataIn.EndOfStream != true)
  80. {
  81. int id = Convert.ToInt32(dataIn.ReadLine());
  82. string fio = dataIn.ReadLine();
  83. string adres = dataIn.ReadLine();
  84. string dat = dataIn.ReadLine();
  85. output = String.Format("{0,-2} {1,-15} {2,-8} {3,-8}", id, fio, adres, dat);
  86. Console.WriteLine(output);
  87. count++;
  88. }
  89. dataIn.Close();
  90. Console.ReadKey();
  91. Console.Clear();
  92. break;
  93. }
  94. case 0:
  95. {
  96. go = false; continue;
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. }

Решение задачи: «Удалить из списка все повторные записи, проверяя Ф.И.О. и домашний адрес»

textual
Листинг программы
  1. if (recindex >= 0 && ADRS[recindex].Equals(adres)) // проверяем значение записи адреса по полученному индексу

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 4 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы