I'll put them together to solve the problem that the input and output that stumble first in the paiza skill check are not what you want.
str
import java.util.*;
public class Main {
public static void main(String[] args) {
/*Reading input value*/
Scanner sc = new Scanner(System.in);
/*Get str*/
String str = sc.nextLine();
/*Output processing*/
System.out.println(str);
}
}
n
import java.util.*;
public class Main {
public static void main(String[] args) {
/*Reading input value*/
Scanner sc = new Scanner(System.in);
/*Get str*/
String n_s = sc.nextLine();
int n = Integer.parseInt(n_s); //Convert to integer type
/*Output processing*/
System.out.println(n);
}
}
n n1 n2 n3 ...
import java.util.*;
public class Main {
public static void main(String[] args) {
/*Reading input value*/
Scanner sc = new Scanner(System.in);
/*Get n*/
String n_s = sc.nextLine();
int n = Integer.parseInt(n_s); //Convert to integer type
/* n1 n2 n3 ...Get*/
//Divide into an array for each element with a character type separated by spaces
String[] datas_s = sc.nextLine().split(" ");
//Convert element to integer type
int[] datas = new int[datas_s.length];
for(int i = 0; i < datas_s.length; i++){
datas[i] = Integer.parseInt(datas_s[i]);
}
/*Output processing*/
System.out.println(n);
System.out.println(Arrays.toString(datas));
}
}
n 1n1 1n2 1n3 2n1 2n2 2n3 3n1 3n2 3n3 ...
import java.util.*;
public class Main {
public static void main(String[] args) {
/*Reading input value*/
Scanner sc = new Scanner(System.in);
/*Get*/
String n_s = sc.nextLine();
int n = Integer.parseInt(n_s); //Convert to integer type
/*Output processing*/
System.out.println(n);
/*Get*/
int[][] datas = new int[10][10]; //Rewrite according to the number of data
for(int i = 0; i < n; i++){
//Divide into an array for each element by character type
String[] datas_s = sc.nextLine().split(" ");
//Convert element to integer type
for(int j = 0; j < datas_s.length; j++){
datas[i][j] = Integer.parseInt(datas_s[j]);
}
/*Output processing*/
System.out.println(Arrays.toString(datas[i]));
}
}
}
Recommended Posts