Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace RegEx{
  6.     class Program{
  7.         public static bool Control(string data){   //Функция поиска
  8.             if(data[0] == ' ' || data[data.Length-1] == ' '){
  9.                 return false;
  10.             }
  11.             Regex regex = new Regex(@"^([0-7])(T[A|B|E]X) \d{4}$");
  12.             MatchCollection matches = regex.Matches(data);
  13.             if (matches.Count == 1){
  14.                 return true;
  15.             }
  16.             return false;
  17.         }
  18.         static void Main(string[] args){
  19.             int n;
  20.             n = int.Parse(Console.ReadLine());
  21.             string line;
  22.             List<string> dataS = new List<string>();
  23.             for (int i = 0; i < n; i++){
  24.                 line = Console.ReadLine();
  25.                 if (Control(line)) {
  26.                    dataS.Add(line);
  27.                 }
  28.             }
  29.            
  30.             string str;
  31.             long tmp = dataS.Count;
  32.             for(int i = 0; i < dataS.Count; i++){
  33.                 str = dataS[i];
  34.                 if(str[0] != '7' && str[2] == 'E'){
  35.                     tmp--;
  36.                 } else if (str.Contains("0000")){
  37.                     tmp--;
  38.                 }
  39.             }
  40.             Console.WriteLine(tmp);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement