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;
- class Program
- {
- static int Main()
- {
- File.WriteAllText("output.txt", String.Empty);
- string line;
- using (StreamReader fileIn = new StreamReader("input.txt"))
- line = fileIn.ReadLine();
- bool flag = true;
- foreach (char elem in line)
- {
- if (Char.IsLetter(elem))
- {
- flag = false;
- break;
- }
- }
- if (flag)
- {
- Console.WriteLine("В файле нету букв");
- return 0;
- }
- Console.WriteLine("Введите нужную букву");
- char ch = char.Parse(Console.ReadLine());
- while(!Char.IsLetter(ch))
- {
- Console.WriteLine("Вы ошиблись, введите букву");
- ch = char.Parse(Console.ReadLine());
- }
- bool s = true;
- foreach (char elem in line)
- {
- if (elem==ch)
- {
- s = false;
- break;
- }
- }
- if (s)
- {
- Console.WriteLine("В файле нету нужной буквы");
- return 0;
- }
- using (StreamWriter fileOut = new StreamWriter("output.txt", false))
- {
- for (int i = 0; i < line.Length - 1; i++)
- {
- if (line[i] == ch)
- {
- fileOut.Write("{0} ", line[i + 1]);
- }
- }
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement