Last active
December 2, 2021 05:19
-
-
Save spiritedRunning/16bd3e974d70234ef8641b12c5f087dc to your computer and use it in GitHub Desktop.
OJ 输入读取方式
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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