Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Удалить из сообщения все повторяющиеся слова.
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace mainSolution
- {
- static class Program
- {
- static void Trim(ref string s)
- {
- s = s.Trim();
- StringBuilder res = new StringBuilder();
- res.Append(s[0]);
- for (int i = 1; i < s.Length; ++i)
- if (s[i] != char.ToLower(s[i - 1]))
- res.Append(s[i]);
- s = res.ToString();
- }
- static void Main(string[] args)
- {
- using (StreamReader inp = new StreamReader("D:/input.txt"))
- {
- Regex Delete_Arcticles = new Regex(@"\b(([Tt]he)|([Aa]n)|([Aa]))\b");
- Regex Ce_To_Se = new Regex("Ce");
- Regex Ci_To_Si = new Regex("Ci");
- Regex ce_To_se = new Regex("ce");
- Regex ci_To_si = new Regex("ci");
- Regex ck_To_k = new Regex(@"ck|c");
- Regex Ck_To_K = new Regex(@"ck|C");
- Regex ee_TO_i = new Regex("ee");
- Regex Ee_TO_I = new Regex("Ee");
- Regex Two_any_To_One = new Regex(@"([a-z | A-Z])\1+");
- Regex Delete_solo_e = new Regex(@"\s[E,e]\s");
- Regex Delete_space = new Regex(@"(\s)\1+|\s$");
- string s = inp.ReadToEnd();
- string ans = s;
- ans = Regex.Replace(ans, Delete_Arcticles.ToString(), "");
- ans = Regex.Replace(ans, Ci_To_Si.ToString(), "Si");
- ans = Regex.Replace(ans, ci_To_si.ToString(), "si");
- ans = Regex.Replace(ans, Ce_To_Se.ToString(), "Se");
- ans = Regex.Replace(ans, ce_To_se.ToString(), "se");
- ans = Regex.Replace(ans, ck_To_k.ToString(), "k");
- ans = Regex.Replace(ans, Ck_To_K.ToString(), "K");
- ans = Regex.Replace(ans, ee_TO_i.ToString(), "i");
- ans = Regex.Replace(ans, Ee_TO_I.ToString(), "I");
- ans = Regex.Replace(ans, Two_any_To_One.ToString(), "$1");
- ans = Regex.Replace(ans, Delete_solo_e.ToString(), "");
- ans = Regex.Replace(ans, Delete_space.ToString(), "$1");
- Trim(ref ans);
- Console.WriteLine(ans);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment