| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- 인공지능
- AP Computer Science A
- 오류역전파
- AP
- MERS
- 파이썬
- 결정트리
- Java
- COVID
- Kaggle
- bioinformatics
- 서열정렬
- 시그모이드
- ncbi
- 생명정보학
- 블록체인
- 자바
- BLaST
- 캐글
- HMM
- SVM
- RNN
- 생물정보학
- 바이오인포매틱스
- CNN
- 바이오파이썬
- 인공신경망
- 딥러닝
- 인공지능 수학
- 이항분포
- Today
- Total
데이터 과학
자리배치 프로그램 -JAVA 본문
JAVA 프로그래밍 공부를 열심히 하는 학생이 문의해 와서 도와준 프로그램입니다.
import java.util.Random;
public class Seat {
static void randomlist(int[] k, int[][] p) { // k = a이고, p는 array로
int[] numbers= new int[36];
boolean chk;
for (int ins=0; ins <k.length; ins++) {
numbers[ins] = (int)(Math.random() * 36) + 1;
for (int nis=0; nis<ins; nis++)
if(numbers[ins]==numbers[nis]){
ins--;
break;
}
}
int f=0;
for (int i = 0; i < p.length; i++) {
for (int j = 0; j < p[i].length; j++) {
p[i][j] = numbers[f];
if (f==35)
break;
else
f++;
} } }
public static void main(String[] args) {
int array[][] = new int[6][6];
array[0] = new int[6];
array[1] = new int[7];
array[2] = new int[6];
array[3] = new int[6];
array[4] = new int[6];
array[5] = new int[5];
// 빈 자리 생성
int a[] = new int[36];
// a라는 배열은 1부터 36까지 중복 없이 랜덤
randomlist(a, array);
for (int x = 0; x < array.length; x++) {
for (int y = 0; y < array[x].length; y++) {
System.out.print(array[x][y] + " ");
}
System.out.println();
} } }
'프로그래밍 언어론 > JAVA 기초' 카테고리의 다른 글
| 배열 (array) (1) | 2022.10.23 |
|---|---|
| return에 대하여 이해하기 (0) | 2022.09.10 |
| 제어문 (5) | 2022.09.04 |
| 연산자 예제, 상속과 캐스팅 (0) | 2022.09.02 |
| JAVA Online compiler (16) | 2022.08.27 |