Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace lab3._2
  9. {
  10. struct Book
  11. {
  12. public string author;
  13. public string name;
  14. public string year;
  15. }
  16.  
  17.  
  18. class Program
  19. {
  20. static void Main(string[] args)
  21. {
  22. string path = "D:\txt.txt";
  23. string path1 = "D:\txt1.txt";
  24. FileStream fstr = File.OpenRead(path);
  25. Book[] Biblio = new Book[10];
  26. StreamReader sr = File.OpenText(path);
  27. StreamWriter sw = new StreamWriter(path1,true);
  28. for (int i = 0; i<=Biblio.Length-1;i++)
  29. {
  30. string parts = sr.ReadLine();
  31. string[] str = parts.Split(',');
  32. Biblio[i].author = str[0];
  33. Biblio[i].name = str[1];
  34. Biblio[i].year = str[2];
  35. }
  36. for (int i = 0; i <= Biblio.Length - 1; i++)
  37. {
  38. Console.WriteLine(Biblio[i].name);
  39. }
  40. Console.WriteLine("avt: ");
  41. string vvd = Console.ReadLine();
  42. for(int i = 0; i<=Biblio.Length-1; i++)
  43. {
  44. if (vvd == Biblio[i].author)
  45. {
  46. sw.WriteLine("Поиск по автору: { 0}nПроизведение: { 1}nДата обращения: { 2}n", Biblio[i].author.ToString(), Biblio[i].name.ToString(), Biblio[i].year.ToString());
  47. // Console.WriteLine("Поиск по автору: {0}nПроизведение: {1}nДата обращения: {2}n",Biblio[i].author, Biblio[i].name, Biblio[i].year);
  48. }
  49.  
  50. }
  51. sw.Close();
  52.  
  53. Console.ReadKey();
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement