服务器之家

服务器之家 > 正文

Java编程在ICPC快速IO实现源码

时间:2020-12-31 15:35     来源/作者:mengwei

        本文将介绍Java在ICPC快速IO实现方法,下面看看具体代码。

不处理EOF:

?
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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
 public static void main(String[] args) {
 InputStream inputStream = System.in;
 OutputStream outputStream = System.out;
 InputReader in = new InputReader(inputStream);
 PrintWriter out = new PrintWriter(outputStream);
 TaskD solver = new TaskD();
 solver.solve(1, in, out);
 out.close();
 }
 static class TaskD {
 public void solve(int testNumber, InputReader in, PrintWriter out) {
 }
 }
 static class InputReader {
 public BufferedReader reader;
 public StringTokenizer tokenizer;
 public InputReader(InputStream stream) {
 reader = new BufferedReader(new InputStreamReader(stream), 32768);
 tokenizer = null;
 }
 public String next() {
 while (tokenizer == null || !tokenizer.hasMoreTokens()) {
 try {
  tokenizer = new StringTokenizer(reader.readLine());
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
 }
 return tokenizer.nextToken();
 }
 public int nextInt() {
 return Integer.parseInt(next());
 }
 }
}

 

处理EOF:

?
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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;
 
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
 public static void main(String[] args) {
 InputStream inputStream = System.in;
 OutputStream outputStream = System.out;
 InputReader in = new InputReader(inputStream);
 PrintWriter out = new PrintWriter(outputStream);
 TaskD solver = new TaskD();
 solver.solve(1, in, out);
 out.close();
 }
 static class TaskD {
 public void solve(int testNumber, InputReader in, PrintWriter out) {
 while(in.hasNext())
 {
 int a=in.nextInt();
 int b=in.nextInt();
 System.out.println(a+b);
 }
 }
 }
 static class InputReader {
 public BufferedReader reader;
 public StringTokenizer tokenizer;
 public InputReader(InputStream stream) {
 reader = new BufferedReader(new InputStreamReader(stream), 32768);
 tokenizer = null;
 }
 public boolean hasNext() {
 while (tokenizer == null || !tokenizer.hasMoreTokens()) {
 try {
  String line = reader.readLine();
  if(line == null) return false;
  tokenizer = new StringTokenizer(line);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
 }
 return true;
 }
 public String next()
 {
 return tokenizer.nextToken();
 }
 public int nextInt() {
 return Integer.parseInt(next());
 }
 }
}

总结

以上就是本文的全部内容,希望对大家有所帮助。感谢大家对本站的支持!

原文链接:https://www.2cto.com/kf/201709/678866.html

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
电视剧《琉璃》全集在线观看 琉璃美人煞1-59集免费观看地址
电视剧《琉璃》全集在线观看 琉璃美人煞1-59集免费观看地址 2020-08-12
返回顶部