IO重定向
作者:
RwChen
,
2023-04-07 10:39:22
,
所有人可见
,
阅读 215
#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
return 0;
}
手动分界
import java.io.*;
import java.util.Scanner;
public class Main {
private static void redirectInput() throws FileNotFoundException {
InputStream fin = new FileInputStream("in.txt");
System.setIn(fin);
}
private static void redirectOutput() throws FileNotFoundException {
OutputStream fout = new FileOutputStream("out.txt");
PrintStream fps = new PrintStream(fout);
System.setOut(fps);
}
public static void main(String[] args) throws FileNotFoundException {
redirectInput();
redirectOutput();
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
System.out.println(sc.nextLine());
}
}
}