Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. // Вывести на кран только буквы и знаки "." и "," удалив из текста цифры и остальные символы.
  2.  
  3. using System;
  4. using System.IO;
  5. using System.Text;
  6.  
  7. class MainClass
  8. {
  9.     public static void Main(string[] args)
  10.     {
  11.         int i;
  12.         string line;
  13.  
  14.         using (StreamReader MyFile = new StreamReader("test.txt"))
  15.         {
  16.             while ((line = MyFile.ReadLine()) != null)
  17.             {
  18.                 i = 0;
  19.                 while (i < line.Length)
  20.                 {
  21.                     while ((i < line.Length) && (char.IsDigit(line, i)))
  22.                     {
  23.                         line = line.Replace(line[i].ToString(), "");
  24.                     }
  25.  
  26.  
  27.                     while ((i < line.Length) && char.IsPunctuation(line, i) && !((line[i] == '.') || (line[i] == ',')))
  28.                     {
  29.                         line = line.Replace(line[i].ToString(), "");
  30.                     }
  31.  
  32.                     while ((i < line.Length) && (char.IsWhiteSpace(line, i)))
  33.                     {
  34.                         line = line.Replace(line[i].ToString(), "");
  35.                     }
  36.  
  37.                     while ((i < line.Length) && ((char.IsLetter(line, i) || (line[i] == '.') || (line[i] == ','))))
  38.                     {
  39.                         i++;
  40.                     }
  41.                 }
  42.                 Console.WriteLine(line);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement