Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Input
- {
- private IEnumerator<string> istream;
- private static IEnumerable<string> GetNullStream()
- {
- while (true) yield return null;
- }
- private static IEnumerator<string> GetIStream()
- {
- while (true)
- {
- IEnumerable<string> sstream;
- try
- {
- sstream = Console.ReadLine().Split().Where(s => s.Length > 0);
- }
- catch (Exception)
- {
- sstream = GetNullStream();
- }
- foreach (string s in sstream)
- yield return s;
- }
- }
- public Input()
- {
- istream = GetIStream();
- }
- public string GetString()
- {
- istream.MoveNext();
- return istream.Current;
- }
- public int GetInt()
- {
- return int.Parse(GetString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement