본문 바로가기

Programming

BankSimulator.h : 은행 시뮬레이션 클래스 #pragma once#ifndef ___BankSimulator#define ___BankSimulator//BankSimulator.h : 은행 시뮬레이션 클래스 #include "CustomerQueue.h"class BankSimulator {int nSimulation;//입력 : 전체 시뮬레이션double probArrival;//입력 : 단위시간에 도착하는 평균 고객 수int tMaxService;//입력 : 한 고객에 대한 최대 서비스 시간int totalWaitTime;//결과 : 고객들이 기다린 전체시간int nCustomers;//결과 : 전체 고객 수int nServedCustomers;//결과 : 서비스 받은 고객 수CustomerQueue que;//고객 대기 큐 //랜덤 숫자를.. 더보기
CustomerQueue.h : 하나의 고객 정보를 관리하기 위한 클래스 #pragma once#ifndef ___CustomerQueue#define ___CustomerQueue //CustomerQueue.h : 하나의 고객 정보를 관리하기 위한 클래스//배열을 이용한 원형 큐 클래스 #include #include #define MAX_QUEUE_SIZE 100//오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);} struct Customer {int id;//고객 번호int tArrival;//고객이 도착한 시간int tService;//이 고객의 서비스에 필요한 시간Customer(int i = 0, int tArr = 0, int tServ = 0):id(i), tArr.. 더보기
CircularDeque.h : CircularQueue 클래스를 상속해서 구현한 원형 덱 클래스 #pragma once#ifndef ___CircularDeque#define ___CircularDeque //CircularDeque.h : CircularQueue 클래스를 상속해서 구현한 원형 덱 클래스#include "CircularQueue.h" class CircularDeque : public CircularQueue {public:CircularDeque(){}void addRear(int val) { enqueue(val); }//enqueue() 호출int deleteFront() { return dequeue(); }//dequeue() 호출int getFront() { return peek(); }//peek() 호출void addFront(int val) {//전단에 삽입if (.. 더보기
ArrayStack.h : 배열을 이용한 int 스택 클래스 #pragma once//ArrayStack.h : 배열을 이용한 int 스택 클래스#ifndef ___ArrayStack#define ___ArrayStack #include #include //오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);} const int MAX_STACK_SIZE = 20;//스택의 최대 크기 설정class ArrayStack {int top;//요소의 개수int data[MAX_STACK_SIZE];//요소의 배열public:ArrayStack() { top = -1; }//스택 생성자(ADT의 create()역할)~ArrayStack() {}//스택 소멸자bool isEmpty(.. 더보기
CircularQueue.h : 배열을 이용한 원형 큐 클래스 #pragma once//배열을 이용한 원형 큐 클래스#ifndef ___CircularQueue#define ___CircularQueue #include #include #define MAX_QUEUE_SIZE 100//오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);} class CircularQueue {protected:int front;//첫 번째 요소 앞의 위치int rear;//마지막 요소 위치int data[MAX_QUEUE_SIZE];//요소의 배열public:CircularQueue() { front = rear = 0; }bool isEmpty() { return front == rear;.. 더보기
Location2D.h : 위치 정보를 나타내는 구조체 #pragma once#ifndef ___Location2D#define ___Location2D struct Location2D {int row;//현재 위치의 행 번호int col;//현재 위치의 열 번호Location2D(int r = 0, int c = 0) { row = r; col = c; }//위치 p가 자신의 이웃인지 검사하는 함수bool isNeighbor(Location2D &p) {return ((row == p.row && (col == p.col - 1 || col == p.col + 1))|| (col == p.col &&row == p.row - 1 || row == p.row + 1));}//위치 p가 자신과 같은 위치인지를 검사하는 함수(연산자 오버로딩)bool operat.. 더보기
OperandStack.h : 피연산자 스택 클래스 #pragma once//OperandStack.h : 피연산자 스택 클래스#ifndef ___OperandStack#define ___OperandStack #include #include const int MAX_STACK_SIZE = 20;//스택의 최대 크기 설정 //오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);}class OperandStack {double data[MAX_STACK_SIZE];//요소의 배열int top;//요소의 개수public:OperandStack() { top = -1; }//스택 생성자bool isEmpty() { return top == -1; }bool isFull(.. 더보기
StudentStack.h : 학생정보 스택 클래스 #pragma once//StudentStack.h : 학생정보 스택 클래스#ifndef ___StudentStack#define ___StudentStack #include "Student.h"const int MAX_STACK_SIZE = 100;//스택의 최대 크기 설정//오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);} class StudentStack {int top;//요소의 개수Student data[MAX_STACK_SIZE];//요소의 배열public:StudentStack() { top = -1; }//스택 생성자bool isEmpty() { return top == -1; }bool isF.. 더보기