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;
- using System.IO;
- namespace ConsoleApplication105
- {
- class Program
- {
- struct knigi
- {
- public string nazvanie;
- public string avtor;
- public string godvyhoda;
- public string izdatelstvo;
- public string sebestoimost;
- public string cena;
- public string pribyl;
- }
- static void Main(string[] args)
- {
- knigi[] kniga = new knigi[3];
- string q = "К";
- string input_path = @"D:\7 лаба\Книга.txt";
- using (StreamReader sr = new StreamReader(input_path, System.Text.Encoding.Default))
- {
- string line;
- int a = 0;
- int b = 0;
- for (int i = 0; i < a; i++)
- {
- line = sr.ReadLine();
- string[] w = line.Split(new char[] { ' ' });
- kniga[i].nazvanie = w[0];
- kniga[i].avtor = w[1];
- kniga[i].godvyhoda = (w[2]);
- kniga[i].izdatelstvo = (w[3]);
- kniga[i].sebestoimost = (w[4]);
- kniga[i].cena = (w[5]);
- kniga[i].pribyl = (w[6]);
- }
- string output_path = @"D:\7 лаба\КнигаЗапись.txt ";
- using (StreamWriter sw = new StreamWriter(output_path, false, System.Text.Encoding.Default))
- {
- for (int i = 0; i < b; i++)
- if ((kniga[i].avtor).Contains(q) & ((kniga[i].avtor).IndexOf(q) == 0))
- {
- sw.WriteLine(kniga[i].nazvanie + " " + kniga[i].avtor + " " + kniga[i].godvyhoda + " " + kniga[i].izdatelstvo + " " + kniga[i].sebestoimost + " " + kniga[i].cena + " " + kniga[i].pribyl);
- }
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement