作った。
class cin { private static Queue<string> tokens; static cin () { string line; tokens = new Queue<string> (); while ((line = Console.ReadLine ()) != null) { foreach (var token in line.Split (' ')) { tokens.Enqueue (token); } } } public static implicit operator int (cin cin) => int.Parse (cin.tokens.Dequeue ()); public static implicit operator string (cin cin) => cin.tokens.Dequeue (); public void Deconstruct (out cin o1, out cin o2) => (o1, o2) = (this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3) => (o1, o2, o3) = (this, this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3, out cin o4) => (o1, o2, o3, o4) = (this, this, this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3, out cin o4, out cin o5) => (o1, o2, o3, o4, o5) = (this, this, this, this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3, out cin o4, out cin o5, out cin o6) => (o1, o2, o3, o4, o5, o6) = (this, this, this, this, this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3, out cin o4, out cin o5, out cin o6, out cin o7) => (o1, o2, o3, o4, o5, o6, o7) = (this, this, this, this, this, this, this); public void Deconstruct (out cin o1, out cin o2, out cin o3, out cin o4, out cin o5, out cin o6, out cin o7, out cin o8) => (o1, o2, o3, o4, o5, o6, o7, o8) = (this, this, this, this, this, this, this, this); }
こんな感じに使う。
int N = cin; string name = cin; (int A, string str, int B) = cin;
castをabuseすると治安の悪いコードが書ける。