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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <iostream> #include <string> using namespace std; class Trace { static string tag[100]; static string info[100]; static int index; public: static void put(string info, string tag); static void print(string tag); static void print(); }; int Trace::index = 0; string Trace::tag[100] = {}; string Trace::info[100] = {}; void Trace::put(string _tag, string _info) { if (index == 100) cout << "스택 꽉 참" << '\n'; tag[index] = _tag; info[index] = _info; index++; } void Trace::print(string _tag) { cout << "-------" << _tag << "태그의 Trace 정보를 출력합니다. -------" << '\n'; for (int i = 0; i < index; i++) { if (tag[i] == _tag) cout << _tag << ":" << info[i] << '\n'; } } void Trace::print() { cout << "------- 모든 Trace 정보를 출력합니다. -------" << '\n'; for (int i = 0; i < index; i++) cout << tag[i] << ":" << info[i] << '\n'; } void f() { int a, b, c; cout << "두 개의 정수를 입력하세요>>"; cin >> a >> b; Trace::put("f()", "정수를 입력 받았음"); c = a + b; Trace::put("f()", "합 계산"); cout << "합은 " << c << endl; } int main() { Trace::put("main()", "프로그램 시작합니다."); f(); Trace::put("main()", "종료"); Trace::print("f()"); Trace::print(); } | cs |
'Programming > 명품 C++ Programming' 카테고리의 다른 글
명품 C++ Programming 실습문제 7장 1번 (0) | 2018.06.17 |
---|---|
명품 C++ Programming 7장 OpenChallenge (0) | 2018.06.17 |
명품 C++ Programming 실습문제 6장 7번 (0) | 2018.05.26 |
명품 C++ Programming 실습문제 6장 6번 (0) | 2018.05.26 |
명품 C++ Programming 실습문제 6장 5번 (0) | 2018.05.10 |