본문 바로가기

언어/C++

원기둥의 반지름과 높이로 부피 구하기 ! argc, argv / CUI, GUI ver #include #include #include using namespace std; int main(int argc,char *argv[]){ int h,r; long double const pi=3.141592; if(argc==2){ h=1; r=atoi(argv[1]); cout 더보기
공 게임 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class ArrayUtility{ public : static int*concat (int s1[], int s2[], int size){ int *s3=new int [size]; int j=0; for(int i=0; i 더보기
항공예약 프로그램 ! #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Console{ public: int menu(){ int num; cout > num; return num; } int time_menu(){ int num; cout >num; return num; } }; class Seat{ string name; int number; public: Seat(){ this->name="---"; this->number=-1; } void setName(string name){ this->name=name; .. 더보기
7장 10번 - 스택 구현하기 #include using namespace std; class Stack { int stack[10]; int top; public : Stack() { top=-1; } Stack& operator (int &n) { n = stack[top]; top--; return *this; } bool operator !() { if( top == -1 ) return true; else return false; } }; int main() { Stack stack; stack 더보기
7장 9번 - 통계 클래스 만들기 #include using namespace std; class Statistics { int *p; int count; public : Statistics(){ p = new int[10]; count=0; } bool operator ! () { if( count == 0 ) return true; else return false; } Statistics& operator 더보기
7장 7번~8번 원 면적 (전위,후위 연산자 개념) #include using namespace std; class Circle { int radius; public : Circle(int radius=0) { this->radius = radius; } void show() { cout 더보기
7장 5~6번 Matrix 연산하기 #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Matrix{ int mat[2][2]; public : Matrix(int a=0,int b=0, int c=0,int d=0){ mat[0][0]=a; mat[0][1]=b; mat[1][0]=c; mat[1][1]=d; } Matrix operator+(Matrix b){ Matrix temp; for(int i=0; i 더보기
7장1번~4번 도서 관리 시스템 (연산자 중복) #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Book { string title; int price; int pages; public : Book(string title="", int price=0, int pages=0){ this->title=title; this->price=price; this->pages=pages; } void show(){ cout 더보기