using System; using System.IO; using System.Text.RegularExpressions; public class Problem1 { public static void Main() { FileStream file = new FileStream("DATA1.txt", FileMode.Open); StreamReader sr = new StreamReader(file); String temp = sr.ReadToEnd(); String[] lines = Regex.Split(temp, "\n"); String output = ""; FileStream file2 = new FileStream("OUT1.txt", FileMode.Create); StreamWriter sw = new StreamWriter(file2); foreach(String ln in lines) { if (ln.Length > 1) { int count = 0; for (int i = 0; i < ln.Length; i++) { if (ln[i] == '#') count++; } output += count.ToString(); } else { sw.WriteLine(output); output = ""; } } sw.Close(); file2.Close(); } }