时间:2021-05-20
本文将介绍Java在ICPC快速IO实现方法,下面看看具体代码。
不处理EOF:
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:
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()); } }}总结
以上就是本文的全部内容,希望对大家有所帮助。感谢大家对本站的支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Java模拟ATM机,供大家参考,具体内容如下实现登录,查询,转账,取款,修改密码,退出功能。源码packagebank;importjava.io.*;imp
之前写了一篇文章:Java网络IO编程总结(BIO、NIO、AIO均含完整实例代码),介绍了如何使用Java原生IO支持进行网络编程,本文介绍一种更为简单的方式
本文实例讲述了Java实现的简单音乐播放器功能。分享给大家供大家参考,具体如下:应用名称:Java简单的音乐播放器用到的知识:JavaGUI编程,线程,IO开发
Java并发编程系列【未完】:•Java并发编程:核心理论•Java并发编程:Synchronized及其实现原理•Java
一、java内部String类的实现:java8:publicfinalclassStringimplementsjava.io.Serializable,Co