-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcSharpInputOutput.cs
142 lines (140 loc) · 3.49 KB
/
cSharpInputOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.IO;
using System.Numerics;
using System.Linq;
namespace Codeforces
{
class Program
{
static void Main(string[] args)
{
InputReader cin = new InputReader();
OutputWriter cout = new OutputWriter();
//read file and write file
//InputReader cin = new InputReader(new System.IO.StreamReader(@"C:\Users\yiqiwu\Desktop\Code\log.txt"));
//OutputWriter cout = new OutputWriter(new System.IO.StreamWriter(@"C:\Users\yiqiwu\Desktop\Code\log.txt"));
while(cin.HasNext())
{
int a = cin.NextInt();
int b = cin.NextInt();
cout.WriteLine(a + b);
}
cout.Close();
}
}
#region ReaderClass
class InputReader
{
private readonly TextReader reader;
private string[] buffer = new string[0];
private int i;
public InputReader()
{
reader = Console.In;
}
public InputReader(TextReader reader)
{
this.reader = reader;
buffer = new string[0];
}
public void Close()
{
reader.Close();
}
public Boolean ReadLine()
{
try
{
buffer = reader.ReadLine().Split(new[] {' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
i = 0;
}
catch (Exception e)
{
return false;
}
return true;
}
public Boolean HasNext()
{
while(buffer.Length == 0 || i == buffer.Length)
{
if(!ReadLine())
{
return false;
}
}
return true;
}
public string NextString()
{
while(buffer.Length == 0 || i == buffer.Length)
{
ReadLine();
}
return buffer[i++];
}
public double NextDouble()
{
return double.Parse(NextString());
}
public int NextInt()
{
return int.Parse(NextString());
}
public long NextLong()
{
return long.Parse(NextString());
}
public BigInteger NextBigInteger()
{
return BigInteger.Parse(NextString());
}
public int[] NextIntArray()
{
ReadLine();
return buffer.Select(int.Parse).ToArray();
}
public double[] NextDoubleArray()
{
ReadLine();
return buffer.Select(double.Parse).ToArray();
}
public long[] NextLongArray()
{
ReadLine();
return buffer.Select(long.Parse).ToArray();
}
public string[] NextStringArray()
{
ReadLine();
return buffer;
}
}
#endregion
#region WriterClass
class OutputWriter
{
TextWriter writer;
public OutputWriter()
{
writer = Console.Out;
}
public OutputWriter(TextWriter writer)
{
this.writer = writer;
}
public void WriteLine(object a)
{
writer.WriteLine(a.ToString());
}
public void Write(object a)
{
writer.WriteLine(a.ToString());
}
public void Close()
{
writer.Close();
}
}
#endregion
}