728x90
[코드 설명] -프로세스 내부 데이터인 프로세스 id와 size를 구조체로 묶어주었다. typedef struct Process { int pid; int size; //size(10~100) }Process; -메모리의 내부 데이터를 프로세스 타입 배열 / 각 프로세스가 사용중인지 여부 표시용 Using배열/ 주소로 두고 구조체로 묶어주었다. typedef struct Memory { Process process[30]; int Using[30]; //각 프로세스 사용중 여부 int address = 0; }Memory; -초기 메모리 상태는 프로세스 5개가 메모리 위에 올라가 있어야 한다. 따라서, for루프를 돌면서 카운터 5이하 프로세스에 한해서 using[]배열에 TRUE값을 주어 메모리 사용처..
[코드 설명] 우선순위 큐에 삽입, 삭제될 Node 속에는 [프로세스 id, 우선순위, 수행시간, 도착시간] 묶음이 포함되어야 한다. 따라서, Node 속에 포함되어야 할 정보들을 구조체로 묶어 정의해두었다, typedef struct Node { //Node 구조체 int pid; //프로세스 id int inputT; //도착시간(>0) int prior; //우선순위 (1~10) int runT; //실행시간 (5~100) }Node; 노드가 삽입 삭제될 ‘우선순위 큐’를 최대힙을 이용해 구현했다. 실질적으로 노드가 삽입 삭제될 노드타입의 힙 배열과 size는 묶어서 구조체로 정의했다. typedef struct priorQueue{ //우선순위 큐 구조체 Node heap[MAX_ELEMENT];..
2.문자열에서 숫자 추출하기 - 화면에서 사용자 입력을 받음. - 화면 아래 '계산' 버튼을 클릭하면, 사용자가 입력한 문자열에서 숫자만 추출한 후, 그 숫자를 모두 더한 값을 출력할 것 [코드 설명] -MyFrame() 클래스 내부에서 이벤트 처리할 수 있도록 JFrame 상속받는 동시에 ActionListener도 implement 시켜두었다. class MyFrame extends JFrame implements ActionListener{ //필드 private JPanel panel; private JButton cal; private JTextArea input; private JTextField output; //생성자 public MyFrame() { this.setSize(350, 300..
1. 소수 출력하기 - 화면에 숫자 10이 초기화되어 있음 - '+' 버튼을 누르면 숫자보다 큰 가장 작은 소수(즉, 10보다 큰 가장 작은 소수는 11)로 문자열을 변경 - '-' 버튼을 누르면 숫자보다 작으면서도 가장 큰 소수(즉 10보다 작은 소수 중 가장 큰 것은 7)로 변경 단, '-'버튼을 누를때 제일 작은 소수는 2이므로, 그 이하로 내려가지 않아야 함 [코드설명] -MyFrame() 클래스 내부에서 이벤트 처리할 수 있도록 JFrame 상속받는 동시에 ActionListener도 implement 시켜두었다. class MyFrame extends JFrame implements ActionListener{ //필드 private JButton plus, minus; private JLab..
[소스코드] [소스코드] Node.java package hwlinkedlist; public class Node { //필드 private String name; private int pointSum; private Node next; //생성자 public Node(String n, int pointMath, int pointKorean, int pointEnglish) { this.name = n; this.pointSum = pointEnglish + pointKorean + pointMath; next = null; } //Getter, Setter 메소드 public String getName() { return name; } public void setName(String name) { th..
package dynamic_beat; public class Main { public static final int SCREEN_WIDTH = 1280; public static final int SCREEN_HEIGHT = 720; public static final int NOTE_SPEED = 3; public static final int SLEEP_TIME= 10; public static final int REACH_TIME = 2; public static void main(String[] args) { new RythmGame(); } } package dynamic_beat; public class Beat { private int time; private String noteType;..