Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- namespace LineNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- using(var reader=new StreamReader("input.txt"))
- {
- using (var writer = new StreamWriter("output.txt"))
- {
- int lineCounter = 1;
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine();
- var lineWithoutSpace = line.Replace(" ", "");
- var listWithChars = lineWithoutSpace.ToCharArray().ToList();
- int sumLetter = 0;
- int sumPunctuationMarks = 0;
- foreach (var symbol in listWithChars)
- {
- if (char.IsLetter(symbol))
- {
- sumLetter++;
- }
- else
- {
- sumPunctuationMarks++;
- }
- }
- writer.WriteLine($"Line {lineCounter}:{line}({sumLetter})({sumPunctuationMarks})");
- listWithChars.Clear();
- lineCounter++;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment