Last active
October 9, 2017 18:56
-
-
Save mizushou/24e5d144f3950fda4a55c047c77e6d47 to your computer and use it in GitHub Desktop.
This file contains 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.util.Scanner; | |
class ConvertToIntArray { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("配列のサイズを入力してください。"); | |
int n = sc.nextInt(); | |
int[] A = new int[n]; | |
System.out.println("配列の要素を空白区切りで入力してください。"); | |
for(int i=0; i<n; i++){ | |
A[i] = sc.nextInt(); | |
}; | |
System.out.print("あなたが入力した配列は : [ "); | |
for(int i=0; i<A.length; i++){ | |
System.out.print(A[i] + " "); | |
}; | |
System.out.println("]"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
標準入力(キーボード)で受け取った数値を整数型の配列にする
1 2 3 4 5