본문 바로가기

C++ Programming

Project 9-67 Euclid's method to get the Greate commom divisor and the Least common muliple 유클리드 소거법으로 최대공약수, 최소공배수 구하기 //============================================================================ // 제출일 : 2005. 4. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 9-67 //============================================================================ #include int get_gcd(int a, int b); //recursive fuction int main() { int gcd; int a, b; cout > a; cout > b; gcd = get_gcd(a, b); cout 더보기
Project 4-41 Create customers' bills 영수증 발행 //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-41 // : Call by Reference를 사용하기 위하여 메인함수에 값을 받아오는 함수를 // 추가하였습니다. 클래스 구조를 사용할 경우 굳이 사용할 필요는 없습니다만 // 주어진 조건에 충실하기 위하여 추가하였습니다. //============================================================================ #include #include #define LABOR 0.35 .. 더보기
Project 4-40 Random number 랜덤 //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-40 //============================================================================ #include #include #include #include int main() { float number; int rand_num; float product; //Process No. cout > number; //2 cout 더보기
Project 4-39 Temperature convertor : Fathrenheit VS Centigrade 온도변환기 : 화씨 섭씨 //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-39 //============================================================================ #include void C2F(float input) //썹씨를 화씨로 고치는 함수 { float output; output = 32 + input*(180/100); //변환식 cout 더보기
Project 4-38 Compute the interest and print the balance //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-38 //============================================================================ #include #include #include #include #include float calc(float input); //이자의 계산 void print(float input); //출력 int main() { float begining_balance; cout > begining.. 더보기
Project 4-37 Prepare a payroll earnings statement //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-37 // data.txt로 부터 세일즈맨의 정보를 읽어와 처리함 //============================================================================ #include #include #include #include #include class Salesperson { public: Salesperson(); //Default 생성자 ~Salesperson(); //소멸자 voi.. 더보기
Problem 4-35 print the ceiling, floor, and rounded value of a floating-point number //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-35 //============================================================================ #include #include float round(float num); int main() { float num; cout > num; cout 더보기
Problem 4-33 Modify the "Add two digit" grogram //============================================================================ // 제출일 : 2005. 3. 12 // 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4 // 연습문제 4-33 //============================================================================ #include //using namespace std; // Prototype Declarations int addThreeDigits (int num); int firstDigit (int); int secondDigit (int); int thirdDigit (int); int ma.. 더보기
Stack calculator #5 - Infix - Postfix translation using Stask structure 첫번째 프로젝트 - Stack Calculator 05 Here is tips and How to make executive file. 몇가지 tip을 먼저 씁니다. makefile a.out : node.o que_handler.o main.o g++ -o a.out node.o que_handler.o main.o node.o : node.h node.cpp g++ -c node.cpp que_handler.o: que_handler.h que_handler.cpp g++ -c que_handler.cpp main.o : main.cpp main.h g++ -c main.cpp g++을 사용할 경우 - linux 에서 코딩할 경우에 사용합니다. 여러개의 파일로 나누어 작업한 파일을 합쳐서 컴파일 및 .. 더보기
Stack calculator #4 - Infix - Postfix translation using Stask structure 첫번째 프로젝트 - Stack Calculator 04 Here is Stack. very simple one. 이번에는 stack 입니다. 매우 단순합니다. templet 를 쓰는 경우가 많은데, 그냥 쉽게 만들었습니다. 물론, 연산자의 프라이어리티도 무시 입니다. -_-;; 스택은 두 가지 입니다. 잘 보시기를.. /////////////////////////////////////////////////////////////////////////////// // File Name : stack.h // // Date : 2004 / 10 / 8 // // Compiler : g++ // // OS : Red Hat Linux 7.1 // //----------------------------------.. 더보기
Stack calculator #3 - Infix - Postfix translation using Stask structure 첫번째 프로젝트 - Stack Calculator 03 Here is File I/O function 이번에는 file I/O 입니다. 간단하죠. /////////////////////////////////////////////////////////////////////////////// // File Name : file.h // // Date : 2004 / 10 / 8 // // Compiler : g++ // // OS : Red Hat Linux 7.1 // //----------------------------------------------------------------// // Etc : Data Strucure Assignment #1 // // Stack Calculator // //.. 더보기
Stack calculator #2 - Infix - Postfix translation using Stask structure 첫번째 프로젝트 - Stack Calculator 02 Here is Main function. main함수 코드는 다음과 같습니다. /////////////////////////////////////////////////////////////////////////////// // File Name : main.h // // Date : 2004 / 10 / 8 // // Compiler : g++ // // OS : Red Hat Linux 7.1 // //----------------------------------------------------------------// // Etc : Data Strucure Assignment #1 // // Stack Calculator // // ver : .. 더보기
Stack calculator #1 - Infix - Postfix translation using Stask structure Stack을 이용하여 infix 수식을 posfix 로 바꾸는 프로그램. 많이들 하는 것이고... 소스도 엄청 많고 공개된 알고리즘들도 많이 있음. 교과서에도 실려있으니... 그럼에도 불구하고... 많은 학생들이 애를 먹는 문제. 내 경우에는 어떠한 알고리즘을 구현하기 전에 손으로 충분한 문제를 풀어봅니다. 어떤 공통된 패턴 내지는 사고의 흐름만 찾아내면 프로그램으로 구현하는 것은 그리 어렵지 않기 때문이죠. 이번 프로그램 같은 경우, 조건의 제한이 ( ) * / - + 로 단순했기 대문에 다른 알고리즘 들보다 훨씬 단순한 알고리즘을 만들어 사용했습니다. 우선 입력과 출력 부터 봅시다. 입력과 출력은 모두 파일로 합니다. 입력 : infix A+B C-D E*F G/H (A*B*C/D)+(E*F+(G*H.. 더보기