Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace lab3._2
- {
- struct Book
- {
- public string author;
- public string name;
- public string year;
- }
- class Program
- {
- static void Main(string[] args)
- {
- string path = "D:\txt.txt";
- string path1 = "D:\txt1.txt";
- FileStream fstr = File.OpenRead(path);
- Book[] Biblio = new Book[10];
- StreamReader sr = File.OpenText(path);
- StreamWriter sw = new StreamWriter(path1,true);
- for (int i = 0; i<=Biblio.Length-1;i++)
- {
- string parts = sr.ReadLine();
- string[] str = parts.Split(',');
- Biblio[i].author = str[0];
- Biblio[i].name = str[1];
- Biblio[i].year = str[2];
- }
- for (int i = 0; i <= Biblio.Length - 1; i++)
- {
- Console.WriteLine(Biblio[i].name);
- }
- Console.WriteLine("avt: ");
- string vvd = Console.ReadLine();
- for(int i = 0; i<=Biblio.Length-1; i++)
- {
- if (vvd == Biblio[i].author)
- {
- sw.WriteLine("Поиск по автору: { 0}nПроизведение: { 1}nДата обращения: { 2}n", Biblio[i].author.ToString(), Biblio[i].name.ToString(), Biblio[i].year.ToString());
- // Console.WriteLine("Поиск по автору: {0}nПроизведение: {1}nДата обращения: {2}n",Biblio[i].author, Biblio[i].name, Biblio[i].year);
- }
- }
- sw.Close();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement