π [ λ°°μ΄μ νμ©]
π μμ : λ°°μ΄μ λͺ¨λ μμλ₯Ό λν΄μ μ΄ν©κ³Ό νκ· κ΅¬νκΈ°
public class practice_10 {
public static void main(String[] args) {
int sum = 0;
float average = 0f;
int [] score = {100, 88, 100, 100, 90};
for(int i =0; i<score.length; i++) {
sum += score[i];
}
average = sum/(float)score.length;
System.out.println("μ΄ν© : " + sum);
System.out.println("νκ· : " + average);
}
}
π μμ : λ°°μ΄μ μμ μ€ μ μΌ ν° κ°κ³Ό μ μΌ μμ κ°μ μ°ΎκΈ°
public class practice_2 {
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];
}else if(score[i] < min) {
min = score[i];
}
}
System.out.println("μ΅λκ°: " +max);
System.out.println("μ΅μκ°: " +min);
}
}
π μμ : λ°°μ΄μ μμμ μμλ₯Ό λ°λ³΅ν΄μ λ°κΎΈκΈ° (μ«μ μκΈ°, λ‘λλ²νΈ μμ±)
import java.util.Arrays;
public class practice_3 {
public static void main(String[] args) {
int [] numArr = {0,1,2,3,4,5,6,7,8,9};
System.out.println(Arrays.toString(numArr));
for(int i=0; i<100; i++) {
int n= (int)(Math.random()*10);
int tmp = numArr[0];
numArr[0] = numArr[n];
numArr[n]= tmp;
}
System.out.println(Arrays.toString(numArr));
}
}
π [ 2μ°¨μλ°°μ΄ ]
π’ 2μ°¨μλ°°μ΄ : ν
μ΄λΈ ννμ λ°μ΄ν°λ₯Ό μ μ₯νκΈ° μν λ°°μ΄
π [ λ©μλλ? ]
π’ λ©μλ : λ¬Έμ₯λ€μ λ¬Άμ΄λμ κ²
- μ½λμ μ€λ³΅μ λ°λμ μ κ±°ν΄μΌν¨
- μμ
λ¨μλ‘ λ¬Έμ₯λ€μ λ¬Άμ΄μ μ΄λ¦ λΆμΈ κ²
π [ String ν΄λμ€ ]
π’ - string ν΄λμ€λ char[]μ λ©μλ(κΈ°λ₯)λ₯Ό κ²°ν©ν κ²
- λ΄μ©μ λ³κ²½ν μ μλ€!