Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- namespace EvenLines
- {
- public class EvenLines
- {
- static void Main()
- {
- string inputFilePath = @"text.txt";
- Console.WriteLine(ProcessLines(inputFilePath));
- }
- public static string ProcessLines(string inputFilePath)
- {
- using StreamReader reader = new StreamReader(inputFilePath);
- char[] symbolArray = new char[] { '-', ',', '.', '!', '?' };
- int counter = 0;
- string line = reader.ReadLine();
- StringBuilder sb = new StringBuilder();
- while (line != null)
- {
- if (counter % 2 == 0)
- {
- foreach (char symbol in symbolArray)
- {
- if (line.Contains(symbol))
- {
- line = line.Replace(symbol, '@');
- }
- }
- string newLine = line.Split().Reverse().ToString();
- sb.AppendLine(newLine);
- }
- counter++;
- line = reader.ReadLine();
- }
- return sb.ToString().Trim();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement