출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    // 10명의 데이터를 입력받도록 한다.
    
    Scanner sc = new Scanner(System.in);
    
    
    // for문으로 풀기
    int arrNum[] = new int[10];
    
    for (int i =0; i<10 ; i++) {
        System.out.println((i+1)+"번째 데이터 = ");
        arrNum[i] = sc.nextInt();
    }
    
    
    // while문으로 풀기
    int numArr[] = new int[10];
    int w1;
    w1=0;
    
    while (w1<10) {
        System.out.println((w1+1+"번째 데이터= ");
        numArr[w1]=sc.nextInt();
        
        w1++;
    }
            
cs

+ Recent posts