Compare commits
4 Commits
f88919aa03
...
caa45609f6
| Author | SHA1 | Date | |
|---|---|---|---|
| caa45609f6 | |||
| 1997997441 | |||
| 03310ecad1 | |||
| dceb3f8b33 |
72
templates/java/BufferedIO.java
Normal file
72
templates/java/BufferedIO.java
Normal file
@@ -0,0 +1,72 @@
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
|
||||
public class BufferedIO {
|
||||
|
||||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
|
||||
static StringTokenizer st;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
// Write code here:
|
||||
|
||||
int a = nextInt();
|
||||
print("You inputted: " + a);
|
||||
|
||||
// Flush
|
||||
|
||||
pw.flush();
|
||||
}
|
||||
|
||||
// Helper IO functions
|
||||
|
||||
static String next() throws IOException {
|
||||
while (st == null || !st.hasMoreTokens())
|
||||
st = new StringTokenizer(br.readLine());
|
||||
return st.nextToken();
|
||||
}
|
||||
|
||||
static int nextInt() throws IOException {
|
||||
return Integer.parseInt(next());
|
||||
}
|
||||
|
||||
static long nextLong() throws IOException {
|
||||
return Long.parseLong(next());
|
||||
}
|
||||
|
||||
static double nextDouble() throws IOException {
|
||||
return Double.parseDouble(next());
|
||||
}
|
||||
|
||||
static String nextLine() throws IOException {
|
||||
return br.readLine();
|
||||
}
|
||||
|
||||
static int[] readIntArray(int n) throws IOException {
|
||||
int[] a = new int[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
a[i] = nextInt();
|
||||
return a;
|
||||
}
|
||||
|
||||
static long[] readLongArray(int n) throws IOException {
|
||||
long[] a = new long[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
a[i] = nextLong();
|
||||
return a;
|
||||
}
|
||||
|
||||
static void println(Object o) {
|
||||
pw.println(o);
|
||||
}
|
||||
|
||||
static void print(Object o) {
|
||||
pw.print(o);
|
||||
}
|
||||
|
||||
static void printf(String fmt, Object... args) {
|
||||
pw.printf(fmt, args);
|
||||
}
|
||||
}
|
||||
75
templates/java/FileIOBuffered.java
Normal file
75
templates/java/FileIOBuffered.java
Normal file
@@ -0,0 +1,75 @@
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
|
||||
public class FileIOBuffered {
|
||||
|
||||
static final String INPUT_FILE = "problem.in"; // ← change to problem name
|
||||
static final String OUTPUT_FILE = "problem.out"; // ← change to problem name
|
||||
|
||||
static BufferedReader br;
|
||||
static PrintWriter pw;
|
||||
static StringTokenizer st;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
br = new BufferedReader(new FileReader(INPUT_FILE));
|
||||
pw = new PrintWriter(new BufferedWriter(new FileWriter(OUTPUT_FILE)));
|
||||
|
||||
// Write code here
|
||||
int t = nextInt();
|
||||
print(t);
|
||||
|
||||
pw.flush();
|
||||
pw.close();
|
||||
}
|
||||
|
||||
// Helper Functions
|
||||
|
||||
static String next() throws IOException {
|
||||
while (st == null || !st.hasMoreTokens())
|
||||
st = new StringTokenizer(br.readLine());
|
||||
return st.nextToken();
|
||||
}
|
||||
|
||||
static int nextInt() throws IOException {
|
||||
return Integer.parseInt(next());
|
||||
}
|
||||
|
||||
static long nextLong() throws IOException {
|
||||
return Long.parseLong(next());
|
||||
}
|
||||
|
||||
static double nextDouble() throws IOException {
|
||||
return Double.parseDouble(next());
|
||||
}
|
||||
|
||||
static String nextLine() throws IOException {
|
||||
return br.readLine();
|
||||
}
|
||||
|
||||
static int[] readIntArray(int n) throws IOException {
|
||||
int[] a = new int[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
a[i] = nextInt();
|
||||
return a;
|
||||
}
|
||||
|
||||
static long[] readLongArray(int n) throws IOException {
|
||||
long[] a = new long[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
a[i] = nextLong();
|
||||
return a;
|
||||
}
|
||||
|
||||
static void println(Object o) {
|
||||
pw.println(o);
|
||||
}
|
||||
|
||||
static void print(Object o) {
|
||||
pw.print(o);
|
||||
}
|
||||
|
||||
static void printf(String fmt, Object... args) {
|
||||
pw.printf(fmt, args);
|
||||
}
|
||||
}
|
||||
21
templates/java/FileIOSimple.java
Normal file
21
templates/java/FileIOSimple.java
Normal file
@@ -0,0 +1,21 @@
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
|
||||
public class FileIOSimple {
|
||||
static final String INPUT_FILE = "problem.in";
|
||||
static final String OUTPUT_FILE = "problem.out";
|
||||
|
||||
static Scanner sc;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
sc = new Scanner(new File(INPUT_FILE));
|
||||
System.setOut(new PrintStream(new File(OUTPUT_FILE)));
|
||||
|
||||
// Write code here
|
||||
|
||||
int a = sc.nextInt();
|
||||
System.out.println(a);
|
||||
|
||||
}
|
||||
}
|
||||
20
templates/java/ScannerSout.java
Normal file
20
templates/java/ScannerSout.java
Normal file
@@ -0,0 +1,20 @@
|
||||
// General imports
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
|
||||
public class ScannerSout {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
// Write code here
|
||||
|
||||
int a = sc.nextInt();
|
||||
System.out.println(a);
|
||||
|
||||
sc.close();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user