(10) 문제

JAVA/간단한 코드 2018. 10. 29. 19:14
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package Studypackage;
 
public class studyclass 
{
    // System.out.print("@"); 명령어로 아래처럼 출력하기
    
    /*
     *     1)             2)            3)
     *    @@@@         @             @@@@
     *    @@@@        @@          @@@
     *    @@@@        @@@       @@
     *    @@@@        @@@@    @
     */
    
    public static void main(String[] args)
    {
        int i , j;
        
        for(i=0;i<4;i++)
        {
            for(j=0;j<4;j++)
            {
                System.out.print("@");
            }
            System.out.println();
        }
        System.out.println();


    
    
        for(i=0;i<4;i++)
        {
            for(j=0;j<=i;j++)
            {
                System.out.print("@");
            }
            System.out.println();
        }
        System.out.println();

        


        for(i=4;i>0;i--)
        {
            for(j=0;j<i;j++)
            {
                System.out.print("@");
            }
            System.out.println();
        }


        
    }
}
 
cs





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
27
28
package Studypackage;
 
import java.util.Arrays;
import java.util.Random;
 
public class studyclass 
{
    
    public static void main(String[] args)
    {
        Random random = new Random();
        
        int[][] score = new int[3][5];
        int sum = 0;
        
        for(int i =0;i<score.length;i++)
        {
            for(int j=0;j<score[0].length;j++)
            {
                score[i][j] = random.nextInt(100+ 1;
                sum += score[i][j];    //    i 값 같고 j는 0~4
            }
            System.out.println(Arrays.toString(score[i]) + " 합계 = " + sum);
            sum = 0;
        }



    }
}
 
cs


'JAVA > 간단한 코드' 카테고리의 다른 글

(11) 문제  (0) 2018.10.30
(9) 문제  (0) 2018.10.28
(7) 문제  (0) 2018.10.24
(5) 문제  (0) 2018.10.22
(4) 문제  (0) 2018.10.21

설정

트랙백

댓글