Last active
September 27, 2020 02:14
-
-
Save yuchiki/acf48855550e40792f719e29348b7ec1 to your computer and use it in GitHub Desktop.
Qiita記事[C#でC++のcinっぽいものを作ってみる](https://qiita.com/yuchiki1000yen/items/53061e3937a7f38e2f74 )で使用しています
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace csharp_Cin | |
{ | |
class Program | |
{ | |
static Cin cin = new Cin(); | |
static void Main(string[] args) | |
{ | |
int N = cin; | |
string name = cin; | |
(int A, string str, int B) = cin; | |
Console.WriteLine(N); | |
Console.WriteLine(name); | |
Console.WriteLine($"{A} {str} {B}"); | |
} | |
} | |
} | |
class Cin { | |
private Queue<string> tokens; | |
public 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment