Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Вывести на кран только буквы и знаки "." и "," удалив из текста цифры и остальные символы.
- using System;
- using System.IO;
- using System.Text;
- class MainClass
- {
- public static void Main(string[] args)
- {
- int i;
- string line;
- using (StreamReader MyFile = new StreamReader("test.txt"))
- {
- while ((line = MyFile.ReadLine()) != null)
- {
- i = 0;
- while (i < line.Length)
- {
- while ((i < line.Length) && (char.IsDigit(line, i)))
- {
- line = line.Replace(line[i].ToString(), "");
- }
- while ((i < line.Length) && char.IsPunctuation(line, i) && !((line[i] == '.') || (line[i] == ',')))
- {
- line = line.Replace(line[i].ToString(), "");
- }
- while ((i < line.Length) && (char.IsWhiteSpace(line, i)))
- {
- line = line.Replace(line[i].ToString(), "");
- }
- while ((i < line.Length) && ((char.IsLetter(line, i) || (line[i] == '.') || (line[i] == ','))))
- {
- i++;
- }
- }
- Console.WriteLine(line);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement