๋ฐฐ์—ด (Array)

๐Ÿ’ก ๊ฐ™์€ ํƒ€์ž…์˜ ์—ฌ๋Ÿฌ ๋ณ€์ˆ˜๋ฅผ ํ•˜๋‚˜์˜ ๋ฌถ์Œ์œผ๋กœ ๋‹ค๋ฃจ๋Š” ๊ฒƒ

๐Ÿ’ก String[] classGroup = { "๊น€์ฒ ์ˆ˜", "๊น€์˜ํฌ", "ํ•œ์†Œํฌ",...}

       โžก๏ธ  classGroup์ด๋ผ๋Š” ๋ณ€์ˆ˜์— ๋ฌธ์ž์—ด๋กœ ๋œ ๋ฐฐ์—ด์ด ๋‹ด๊ธด๋‹ค.

 

โ€‹

1)  ๋ฐฐ์—ด์˜ ์„ ์–ธ๊ณผ ์ƒ์„ฑ

์„ ์–ธ๋ฐฉ๋ฒ• ์„ ์–ธ ์˜ˆ
ํƒ€์ž…[] ๋ณ€์ˆ˜์ด๋ฆ„; int[] score;
String[] name;
ํƒ€์ž… ๋ณ€์ˆ˜์ด๋ฆ„[]; int score[];
String name[];

 

a.  ๋ฐฐ์—ด์˜ ์ƒ์„ฑ

ํƒ€์ž…[] ๋ณ€์ˆ˜์ด๋ฆ„;                         //  ๋ฐฐ์—ด์„ ์„ ์–ธ (๋ฐฐ์—ด์„ ๋‹ค๋ฃจ๊ธฐ ์œ„ํ•œ ์ฐธ์กฐ๋ณ€์ˆ˜ ์„ ์–ธ)
๋ณ€์ˆ˜์ด๋ฆ„ = new ํƒ€์ž…[๊ธธ์ด];    //  ๋ฐฐ์—ด์„ ์ƒ์„ฑ (์‹ค์ œ ์ €์žฅ๊ณต๊ฐ„์„ ์ƒ์„ฑ)

 

  ๐Ÿ“  ๊ฐ ๋ฐฐ์—ด์š”์†Œ๋Š” ์ž๋™์ ์œผ๋กœ int์˜ ๊ธฐ๋ณธ๊ฐ’(default)์ธ 0์œผ๋กœ ์ดˆ๊ธฐํ™”

 


โ€‹

 2)  ๋ฐฐ์—ด์˜ ๊ธธ์ด์™€ ์ธ๋ฑ์Šค

 

  ๐Ÿš€  ์ƒ์„ฑ๋œ ๋ฐฐ์—ด์˜ ๊ฐ ์ €์žฅ๊ณต๊ฐ„์„ '๋ฐฐ์—ด์˜ ์š”์†Œ(element)'๋ผ๊ณ  ํ•˜๋ฉฐ, '๋ฐฐ์—ด์ด๋ฆ„[์ธ๋ฑ์Šค]'์˜ ํ˜•์‹์œผ๋กœ ๋ฐฐ์—ด์˜ ์š”์†Œ์— ์ ‘๊ทผํ•œ๋‹ค.

  ๐Ÿš€  ์ธ๋ฑ์Šค(index)๋Š” ๋ฐฐ์—ด์˜ ์š”์†Œ๋งˆ๋‹ค ๋ถ™์—ฌ์ง„ ์ผ๋ จ๋ฒˆํ˜ธ

         โžก๏ธ  ์ธ๋ฑ์Šค์˜ ๋ฒ”์œ„๋Š” 0๋ถ€ํ„ฐ '๋ฐฐ์—ด๊ธธ์ด -1'๊นŒ์ง€

         โžก๏ธ  ์ธ๋ฑ์Šค๋กœ ์ƒ์ˆ˜ ๋Œ€์‹  ๋ณ€์ˆ˜๋‚˜ ์ˆ˜์‹๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค

โ€‹score[0] = 0 ;
score[1] = 10;
score[2] = 20;
score[3] = 30;
score[4] = 40;

โ€‹* [0],[1],[2],[3],..  : '์ธ๋ฑ์Šค'(์œ„์น˜๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ์›๋ฆฌ)
for (int i = 0; i < 5; i++) {
    score[i] = i * 10;
}

 

a.  ๋ฐฐ์—ด์˜ ๊ธธ์ด

    · ๋ฐฐ์—ด์˜ ๊ธธ์ด๋Š” ์–‘์˜ ์ •์ˆ˜(0๋„ ํฌํ•จ) ์ด์–ด์•ผ ํ•˜๋ฉฐ ์ตœ๋Œ€๊ฐ’์€ int ํƒ€์ž…์˜ ์ตœ๋Œ€๊ฐ’, ์•ฝ 20์–ต์ด๋‹ค

 

b.  ๋ฐฐ์—ด์ด๋ฆ„.length

    ·  ๋ฐฐ์—ด์€ ํ•œ๋ฒˆ ์ƒ์„ฑํ•˜๋ฉด ๊ธธ์ด๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์—, ์ด๋ฏธ ์ƒ์„ฑ๋œ ๋ฐฐ์—ด์˜ ๊ธธ์ด๋Š” ๋ณ€ํ•˜์ง€ ์•Š๋Š”๋‹ค.

    ·  '๋ฐฐ์—ด์ด๋ฆ„.length'๋Š” ์ƒ์ˆ˜๋‹ค.

    ·  for๋ฌธ์˜ ์กฐ๊ฑด์‹์— ๋ฐฐ์—ด์˜ ๊ธธ์ด๋ฅผ ์ง์ ‘ ์ ์–ด์ฃผ๋Š” ๊ฒƒ๋ณด๋‹ค. '๋ฐฐ์—ด์ด๋ฆ„.length'๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

 

c.  ๋ฐฐ์—ด์˜ ๊ธธ์ด ๋ณ€๊ฒฝํ•˜๊ธฐ

 

  1) ๋” ํฐ ๋ฐฐ์—ด์„ ์ƒˆ๋กœ ์ƒ์„ฑ

  2) ๊ธฐ์กด ๋ฐฐ์—ด์˜ ๋‚ด์šฉ์„ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด์— ๋ณต์‚ฌ

 

 

โ€‹

3)  ๋ฐฐ์—ด์˜ ์ดˆ๊ธฐํ™”

  ๐Ÿš€  ๋ฐฐ์—ด์€ ์ƒ์„ฑ๊ณผ ๋™์‹œ์— ์ž๋™์ ์œผ๋กœ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™” ๋จ

         โžก๏ธ  ์›ํ•˜๋Š” ๊ฐ’์„ ์ €์žฅํ•˜๋ ค๋ฉด ๊ฐ ์š”์†Œ๋งˆ๋‹ค ๊ฐ’์„ ์ง€์ •ํ•ด์ค˜์•ผ ํ•จ

         โžก๏ธ  ๋ฐฐ์—ด์˜ ๊ธธ์ด๊ฐ€ ํฐ ๊ฒฝ์šฐ์—๋Š” ์š”์†Œ ํ•˜๋‚˜ํ•˜๋‚˜์— ๊ฐ’์„ ์ง€์ •ํ•˜๊ธฐ ๋ณด๋‹ค๋Š” for๋ฌธ์„ ์‚ฌ์šฉ

int score = new int [] { a , b, c, d, e };    //  ๋ฐฐ์—ด์˜ ์ƒ์„ฑ๊ณผ ์ดˆ๊ธฐํ™”๋ฅผ ๋™์‹œ์—
int score = { a , b, c, d, e };                        //  new int[] ๋ฅผ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ์Œ
 (๋‹จ, ๋ฐฐ์—ด์˜ ์„ ์–ธ๊ณผ ์ƒ์„ฑ์„ ๋”ฐ๋กœํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ์ƒ๋žต ๋ถˆ๊ฐ€)
 
int[] score = new int[0];     // ๊ธธ์ด๊ฐ€ 0์ธ ๋ฐฐ์—ด
int[] score = new int[]{};    // ๊ธธ์ด๊ฐ€ 0์ธ ๋ฐฐ์—ด
int[] score = {};             // ๊ธธ์ด๊ฐ€ 0์ธ ๋ฐฐ์—ด, new int [ ] ๊ฐ€ ์ƒ๋žต๋จ

 


โ€‹

4)  ๋ฐฐ์—ด์˜ ์ถœ๋ ฅ

  ๐Ÿš€  for๋ฌธ ์‚ฌ์šฉ ๋˜๋Š” Arrays.toString(๋ฐฐ์—ด์ด๋ฆ„) ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ

          → ๋ฐฐ์—ด์˜ ๋ชจ๋“  ์š”์†Œ๋ฅผ '[์ฒซ๋ฒˆ์งธ ์š”์†Œ, ๋‘๋ฒˆ์งธ ์š”์†Œ, ...]' ์™€ ๊ฐ™์€ ํ˜•์‹์˜ ๋ฌธ์ž์—ด๋กœ ๋งŒ๋“ค์–ด์„œ ๋ฐ˜ํ™˜

  ๐Ÿš€  ์•„๋ž˜ ๋ณ€์ˆ˜ iArr ๊ฐ’์„ ๋ฐ”๋กœ ์ถœ๋ ฅํ•˜๋ฉด 'ํƒ€์ž… @ ์ฃผ์†Œ' ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅ๋œ๋‹ค.

        ์ฐธ์กฐ๋ณ€์ˆ˜๋Š” heap ์˜์—ญ์—, ์ง€์—ญ๋ณ€์ˆ˜&๋งค๊ฐœ๋ณ€์ˆ˜๋Š” stack ์˜์—ญ์— ์ €์žฅ ๋จ.

-> ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์ฐธ์กฐ ๋ณ€์ˆ˜๋Š” ์ฃผ์†Œ๋กœ ์ถœ๋ ฅ๋จ.

int[] iArr = {100, 95, 80, 70, 60}; 

for(int i = 0; i < iArr.length; i++) {
    System.out.println(iArr[i] + ","); 
}

System.out.println();  
System.out.prinln(iArr); // [I@7344699f
System.out.prinln(Arrays.toString(iArr)); // [100, 95, 80, 70, 60]

 


  โœ“  ๋ฉ”๋ชจ๋ฆฌ ๊ตฌ์กฐ

 

โ˜• ๊ทธ๋ฆผ์œผ๋กœ ๋ณด๋Š” ์ž๋ฐ” ์ฝ”๋“œ์˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ(์Šคํƒ & ํž™)

์ž๋ฐ”์˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„  ์ž๋ฐ”(JAVA)๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ž…์žฅ์—์„œ ์•Œ์•„์•ผ ํ•  ๋ฉ”๋ชจ๋ฆฌ ๊ตฌ์กฐ ๋ฐ ํŠน์ง•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ์ž๋ฐ” ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋ฉด JVM(์ž๋ฐ” ๊ฐ€์ƒ ๋จธ์‹ )์€ OS๋กœ๋ถ€ํ„ฐ ๋ฉ”๋ชจ

inpa.tistory.com

 


 

public class Exam01 {

	public static void main(String[] args) {
		
		int[] student; // ํž™๊ณต๊ฐ„์˜ ๋ฐฐ์—ด์˜ ์ฃผ์†Œ๊ฐ€ ์ €์žฅ๋  ๋ณ€์ˆ˜ ์ƒ์„ฑ.
		student = new int[3]; // ํž™๊ณต๊ฐ„์˜ ๊ธธ์ด๊ฐ€ 3์ธ ๋ฐฐ์—ด ์ƒ์„ฑ(์—ฐ์†๋œ ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง)ํ•˜๊ณ  ์ฃผ์†Œ๋ฅผ ๋ฐ˜ํ™˜.

		// ์ •์ˆ˜ ๋ฐฐ์—ด์ด ์ƒ์„ฑ์ด ๋˜๊ณ , ์ดˆ๊ธฐํ™”๋ฅผ ํ•˜์ง€ ์•Š์œผ๋ฉด ์ž๋™์œผ๋กœ 0์œผ๋กœ ์ดˆ๊ธฐํ™”.
		System.out.println("ํ˜„์žฌ ์ž๋™์œผ๋กœ ์ดˆ๊ธฐํ™”๋œ ๊ฐ’: " + student[0]); // 0

		// ์ธ๋ฑ์Šค๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐœ๋ณ„ ์š”์†Œ์˜ ๊ฐ’์„ ๋ณ€๊ฒฝ.
		student[0] = 30; // ๋ฐฐ์—ด์˜ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ์— 30์„ ์ €์žฅ
		student[1] = 20; // ๋ฐฐ์—ด์˜ ๋‘ ๋ฒˆ์งธ ์š”์†Œ์— 20์„ ์ €์žฅ
	    student[2] = 10; // ๋ฐฐ์—ด์˜ ์„ธ ๋ฒˆ์งธ ์š”์†Œ์— 10์„ ์ €์žฅ
	    
	    System.out.println("ํ˜„์žฌ ์ฒซ ๋ฒˆ์งธ ์š”์†Œ์˜ ๊ฐ’: " + student[0]); // 30
	}
}

โ€‹

๋ฐฐ์—ด ์ถœ๋ ฅ 3๊ฐ€์ง€ ๋ฐฉ๋ฒ•

 

  ๐Ÿ“  for๋ฌธ ์ถœ๋ ฅ  |  foreach๋ฌธ ์ถœ๋ ฅ  |  Array.toString() ์ถœ๋ ฅ 

public class Exam02 {

	public static void main(String[] args) {
    
		// for๋ฌธ์œผ๋กœ ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”
		int[] c = new int[10];
		for(int i = 0; i < c.length; i++) {
			c[i] = i;
		}
		
		// ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฐฉ๋ฒ• 3๊ฐ€์ง€.
		// for๋ฌธ์„ ์ด์šฉํ•œ ์ถœ๋ ฅ
		System.out.println(c.length);
		for (int i = 0; i < c.length; i++) {
			System.out.println(c[i]);
		}
		
		// foreach ๋ฌธ์„ ์ด์šฉํ•œ ์ถœ๋ ฅ
		System.out.println();
		for(int d: c) { // (๋ฐฐ์—ด์˜ ์š”์†Œ : ๋ฐฐ์—ด).
			// ๋ฐ˜๋ณต์‹œ์— ๋ณ€์ˆ˜ d์— ์ˆœ์„œ๋Œ€๋กœ ์š”์†Œ๊ฐ€ ๋“ค์–ด๊ฐ. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ for of๋ฌธ๊ณผ ์œ ์‚ฌ.
			System.out.println(d);
		}
		
		// Arrays.toString ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ. ๋ฌธ์ž์—ด๋กœ ์ถœ๋ ฅ.
	    System.out.println();
	    System.out.println(Arrays.toString(c));

	}
}

 

 
 
 
๋ฐฐ์—ด ์‚ฌ์šฉ X  VS. ๋ฐฐ์—ด ์‚ฌ์šฉ O

  โœ”๏ธ  ํ•™์ƒ 5๋ช…์˜ ์„ฑ์  ์ด์ ๊ณผ ํ‰๊ท 

public class MyArray_01 {

	public static void main(String[] args) {
	
		// 1. ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
	    int score_001 = 95;
	    int score_002 = 76;
	    int score_003 = 67;
	    int score_004 = 56;
	    int score_005 = 87;
	    
	    int total = score_001 + score_002 + score_003 + score_004 + score_005;
	    double avg = (double)total / 5;
	    System.out.println("์ด์ ์€ " + total + "์ ์ด๊ณ , ํ‰๊ท ์€ " + avg + "์ž…๋‹ˆ๋‹ค.");
	    
	    // 2. ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ
	    // ์ด์ ์€ for๋ฌธ์„ ์ด์šฉํ•ด์„œ ๊ตฌํ•  ์ˆ˜ ์žˆ๊ณ , ๋ฐฐ์—ด์˜ ๊ฐฏ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚œ๋‹ค ํ•ด๋„
	    // ์ด์ ์„ ๊ตฌํ•˜๋Š” for๋ฌธ๊ณผ ํ‰๊ท ์„ ๊ตฌํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•  ํ•„์š”๊ฐ€ ์—†์Œ
	    total = 0;
	    int[] scores = {95, 76, 67, 56, 87}; // ๋ฐฐ์—ด ์ƒ์„ฑ
	    for (int i = 0; i < scores.length; i++) {// scores.length -> ๋ฐฐ์—ด์˜ ๊ฐฏ์ˆ˜
	    	total += scores[i];
	    	
	    }
	    avg = (double)total / scores.length;
	    System.out.println("์ด์ ์€ " + total + "์ ์ด๊ณ , ํ‰๊ท ์€ " + avg + "์ž…๋‹ˆ๋‹ค.");
	}
}

 

์ตœ๋Œ€๊ฐ’ ์ตœ์†Œ๊ฐ’ ๊ตฌํ•˜๊ธฐ
public class MyArray_03 {

	public static void main(String[] args) {
		/* ์ตœ๋Œ€๊ฐ’, ์ตœ์†Œ๊ฐ’ ๊ตฌํ•˜๊ธฐ */
		int[] score = { 79, 88, 91, 33, 100, 55, 95 };
		
		int max = score[0]; // ๋ฐฐ์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๊ฐ’์œผ๋กœ ์ตœ๋Œ€๊ฐ’์„ ์ดˆ๊ธฐํ™” ํ•œ๋‹ค.
		int min = score[0]; // ๋ฐฐ์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๊ฐ’์œผ๋กœ ์ตœ์†Œ๊ฐ’์„ ์ดˆ๊ธฐํ™” ํ•œ๋‹ค.
		
		for(int i = 1; i < score.length; i++) {
			if(score[i] > max) {
				max = score[i];
			    System.out.println("max: " + max); // ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋Š” ๊ฒƒ์ด ์•ˆ ๋ณด์ด๊ธฐ ๋•Œ๋ฌธ์— ์ดํ•ด๊ฐ€ ์•ˆ๋  ๋•Œ ์จ๋ณด๊ธฐ.
			}
			if(score[i] < min) {
				min = score[i];
			}
		} // end of for
		
		System.out.println("์ตœ๋Œ€๊ฐ’ : " + max);
	    System.out.println("์ตœ์†Œ๊ฐ’ : " + min);

	}
}
 
 

 

โ€‹์‘์šฉ ๋ฌธ์ œ
  ๐Ÿ“ ํ•™์ƒ ์ˆ˜์™€ ๊ฐ ํ•™์ƒ๋“ค์˜ ์ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ, ์ตœ๊ณ  ์ ์ˆ˜ ๋ฐ ํ‰๊ท  ์ ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ
public class Ex_01_Array_03 {

	public static void main(String[] args) {
		
        Scanner scanner = new Scanner(System.in);
		
        boolean run = true;  // ๋ฐ˜๋ณต๋ฌธ์˜ ์กฐ๊ฑด์œผ๋กœ ์‚ฌ์šฉ -> ๊ฐ’์ด false๊ฐ€ ๋œ๋‹ค๋ฉด ๋ฐ˜๋ณต๋ฌธ์ด ์ข…๋ฃŒ
        int studentNum = 0;  // ํ•™์ƒ์ˆ˜
        int[] scores = null; // ์ ์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›์„ ๋นˆ ๋ฐฐ์—ด ์ƒ์„ฑ. ์‚ฌ์šฉ์ž์—๊ฒŒ ์ž…๋ ฅ๋ฐ›์€ ํ•™์ƒ์ˆ˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฐฐ์—ด ์ƒ์„ฑ.
        
        
        while (run) {
        
            System.out.println("-----------------------------------------------------");
            System.out.println("1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ");
            System.out.println("-----------------------------------------------------");
            System.out.print("์„ ํƒ> ");
           
            int selectNo = scanner.nextInt();
          
            if (selectNo == 1) { // ํ•™์ƒ์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„์„œ ๋ฐฐ์—ด ์ƒ์„ฑ 
     
                System.out.print("ํ•™์ƒ์ˆ˜> ");
                studentNum = scanner.nextInt();
                scores = new int[studentNum];
                
                System.out.println(Arrays.toString(scores));
                
            } else if (selectNo == 2) { // ์ƒ์„ฑ๋œ ๋ฐฐ์—ด์˜ ๊ฐฏ์ˆ˜ ๋งŒํผ ์ ์ˆ˜ ์ž…๋ ฅ
            	
                for(int i = 0; i < scores.length; i++) {
                	System.out.print("scores["+i+"] : ");
                	scores[i] = scanner.nextInt();
                }
            	
            } else if (selectNo == 3) { // ์ž…๋ ฅ๋ฐ›์€ ๋ฐฐ์—ด์˜ ๊ฐ’์„ ์ถœ๋ ฅ

            	for(int i = 0; i < scores.length; i++) {
                    System.out.println("score["+i+"] : " + scores[i]);
            	}
            	
            } else if (selectNo == 4) { // ์ตœ๊ณ  ์ ์ˆ˜, ํ‰๊ท  ์ ์ˆ˜ ์ถœ๋ ฅ
                
            	int max = 0;
            	int sum = 0;
            	double avg = 0;
            	
            	for(int i = 0; i < scores.length; i++) {
            		max = (max < scores[i]) ? scores[i] : max;
            		sum += scores[i];
        		}
                
        		avg = (double) sum / studentNum; // ํ‰๊ท 
        		System.out.println("์ตœ๊ณ  ์ ์ˆ˜: " + max);
            	System.out.println("ํ‰๊ท  ์ ์ˆ˜: " + avg);
            	
            } else if (selectNo == 5) { // run ๊ฐ’ ๋ณ€๊ฒฝ
                run = false;
            }
        }
        System.out.println("ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ");
        scanner.close();
    }
}
 
 ์‹คํ–‰ ์˜ˆ)
        -----------------------------------------------------
        1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ
        -----------------------------------------------------
        ์„ ํƒ> 1
        ํ•™์ƒ์ˆ˜> 3
        [0, 0, 0]
        -----------------------------------------------------
        1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ
        -----------------------------------------------------
        ์„ ํƒ> 2
        scores[0]> 90
        scores[1]> 80
        scores[2]> 70
        -----------------------------------------------------
        1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ
        -----------------------------------------------------
        ์„ ํƒ> 3
        scores[0]: 90
        scores[1]: 80
        scores[2]: 70
        -----------------------------------------------------
        1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ
        -----------------------------------------------------
        ์„ ํƒ> 4
        ์ตœ๊ณ  ์ ์ˆ˜: 90
        ํ‰๊ท  ์ ์ˆ˜: 80.0
        -----------------------------------------------------
        1.ํ•™์ƒ์ˆ˜ | 2.์ ์ˆ˜์ž…๋ ฅ | 3.์ ์ˆ˜๋ฆฌ์ŠคํŠธ | 4.๋ถ„์„ | 5.์ข…๋ฃŒ
        -----------------------------------------------------
        ์„ ํƒ> 5
        ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ

 

โ€‹

 
 
 

 

* ๋‚ด์šฉ ์ฐธ๊ณ  : ํ•™์›๊ฐ•์˜ ๋ฐ ์ž๋ฐ”์˜ ์ •์„ 3rd

 

+ Recent posts