Skip to content

Instantly share code, notes, and snippets.

@spiritedRunning
Last active December 2, 2021 05:19
Show Gist options
  • Save spiritedRunning/16bd3e974d70234ef8641b12c5f087dc to your computer and use it in GitHub Desktop.
Save spiritedRunning/16bd3e974d70234ef8641b12c5f087dc to your computer and use it in GitHub Desktop.
OJ 输入读取方式
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
// 直接读取多行数据
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + b);
}
}
}
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt(); // 读取个数
for (int i = 0; i < n; i++) {
double x = sc.nextDouble();
double y = sc.nextDouble();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment