자바로 배우는 프로그래밍 7장
본 자료는 6페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
해당 자료는 6페이지 까지만 미리보기를 제공합니다.
6페이지 이후부터 다운로드 후 확인할 수 있습니다.

목차

1. 7장 내용점검

2. 7장 프로그래밍 연습

본문내용

VALUE);
System.out.println("\t\t 최대값: " + Character.MAX_VALUE);
}
}
3. 20개의 수(0에서 9까지의 정수)를 입력 받아 그 빈도 수가 가장 많은 수와 빈도 수를
출력하는 프로그램을 작성하시오.
import java.util.Scanner;
public class no3 {
public static void main(String[] args) {
int max=0;
int[] num = new int[20];
int[] count = new int[20];
Scanner s = new Scanner(System.in);
System.out.print("0에서 9까지의 정수 20개를 입력하시오: ");
for(int i=0; i num[i] = s.nextInt();
}
s.close();
for(int i=0; i int n=0;
for(int j=0; j if(num[i]==num[j]) n++;
}
count[i]=n;
for(int k=0; k if(count[i]>count[k]) max=i;
}
}
System.out.println("빈도수가 가장 많은 수: " + num[max]);
System.out.println("그 숫자의 빈도 횟수: " + count[max]);
}
}
4. 다음 표의 가로 합과 세로 합, 그리고 모든 수의 합을 구하는 프로그램을 작성하시오.
public class no4 {
public static void main(String[] args) {
int array[][] = {{35, 28, 67, 73}, {25, 32, 12, 69},
{97, 56, 14, 23}, {45, 97, 48, 15}};
int totalSum=0;
for(int i=0; i int widthSum=0, heightSum=0;
for(int j=0; j widthSum += array[i][j];
heightSum += array[j][i];
}
System.out.print((i+1) + "n번째 가로의 합: " + widthSum);
System.out.println("\t세로의 합: " + heightSum);
totalSum += widthSum;
}
System.out.println("\n모든 수의 합: " + totalSum);
}
}
5. 다음 3*3의 두 배열에서, 같은 첨자의 행과 열에 대응하는 원소의 합과 차를 구하는
(행렬의 합과 차를 구하는) 프로그램을 작성하시오.
public class no5 {
public static void main(String[] args) {
int[][] array1 = {{35, 28, 73}, {25, 32, 69}, {97, 56, 23}, {45,97,15}};
int[][] array2 = {{125, 28, 56}, {32, 32, 69}, {57, 56, 59}, {45, 33, 45}};
int[][] sum = new int[array1.length][array1[0].length];
int[][] blance = new int[array2.length][array2[0].length];
System.out.println("\t<<행렬의 합과 차를 구하는 프로그램>>\n");
for(int i=0; i for(int j=0; j sum[i][j] = array1[i][j] + array2[i][j];
System.out.print("\t행렬의 합[" + (i+1) + "][" + (j+1)
+ "]= " + sum[i][j]);
}
System.out.println();
}
System.out.println();
for(int i=0; i for(int j=0; j blance[i][j] = array1[i][j] - array2[i][j];
System.out.print("\t행렬의 차[" + (i+1) + "][" + (j+1)
+ "]= " + blance[i][j]);
}
System.out.println();
}
}
}
6. 예제 프로그램 SelectionSort를 수정하여 표준 입력으로 n개의 자료를 입력 받아
정렬의 결과를 출력하는 프로그램을 작성하시오.
import java.util.Scanner;
public class no6 {
public static void main(String[] args) {
int input[] = new int[10];
Scanner s = new Scanner(System.in);
System.out.println("\t<<입력된 정수를 작은 것 부터 정렬하는 프로그램>>\n");
System.out.print("입력할 자료(저웃) 갯수 입력: ");
int n = s.nextInt();
System.out.print("위에서 입력한 갯수만큼 정수 입력: ");
for(int i=0; i input[i] = s.nextInt();
}
s.close();
int start=0;
while(start int minIndex = start;
for(int i=start+1; i if(input[minIndex] > input[i]) {
minIndex = i;
}
}
if(minIndex != start) {
int dummy;
dummy = input[start];
input[start] = input[minIndex];
input[minIndex] = dummy;
}
start++;
}
System.out.print("정렬의 결과는 ==> ");
for(int i=0; i System.out.print(input[i] + " ");
}
}
}
  • 가격2,000
  • 페이지수18페이지
  • 등록일2008.06.10
  • 저작시기2007.10
  • 파일형식한글(hwp)
  • 자료번호#468881
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니