/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 310 - Problem 9: Stream of Bits */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static void Main(string[] args) { int count101 = 0, count11 = 0; char x = '!'; while(x != '~') { x = Console.ReadKey().KeyChar; if(x == '1') { x = Console.ReadKey().KeyChar; if (x == '1') count11++; else if(x == '0') { x = Console.ReadKey().KeyChar; if (x == '1') count101++; } } } Console.WriteLine("\n\nPattern 101 found: {0}", count101); Console.WriteLine("Pattern 11 found: {0}", count11); Console.ReadKey(); } } }