public class ArrayEx2{
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];
}
if(score[i] < min){
max = score[i];
}
}
System.out.println("최대값 : " +max);
System.out.println("최소값 : " +min);
}
}
public class ArrayEx10 {
public static void main(String[] args){
int[][] score = {{ 100, 100, 100}
,{20, 20, 20}
,{30, 30, 30}
,{40, 40, 40}
,{50, 50, 50}};
int koreanTotal = 0;
int englishTotal = 0;
int mathTotal = 0;
System.out.println("번호 국어 영어 수학 총점 평균 ");
System.out.println("==========================");
for(int i=0; i<score.length; i++){
int sum=0;
koreanTotal += score[i][0];
englishTotal += score[i][1];
mathTotal += score[i][2];
System.out.print(" " +(i+1) +" ");
for(int j=0; j<score[i].length; j++){
sum += score[i][j];
System.out.print(score[i][j]+" ");
}
System.out.println(sum + " " +sum/(float)score[i].length);
}
System.out.println("==========================");
System.out.println("총점 : " +koreanTotal +" " +englishTotal +" " +mathTotal);
}
}
'Study > Programming' 카테고리의 다른 글
자바스크립트 ID 저장, 중복체크 (0) | 2009.05.16 |
---|---|
자바스크립트 달력 (0) | 2009.05.15 |
자바 String, StringBuffer (0) | 2009.05.15 |
자바 equals (0) | 2009.05.15 |
자바스크립트 문자열 비교 (0) | 2009.05.14 |