πŸ’» Dev & CSC++ Programming

C++ Programming Ch.6 Exercise 2 Solution

Problem: Person 클래슀의 객체λ₯Ό μƒμ„±ν•˜λŠ” main() ν•¨μˆ˜λŠ” λ‹€μŒκ³Ό κ°™λ‹€. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Person { int id; double weight; string name; public: void show() { cout << id << ' ' << weight << ' ' << name << endl; } }; int main() { Person grace, ashley(2, "Ashley"), helen(3, "Helen", 32.5); grace.show(); ashley.show(); helen.show(); } (1) μƒμ„±μžλ₯Ό 쀑볡 μž‘μ„±ν•˜κ³  ν”„λ‘œκ·Έλž¨μ„ μ™„μ„±ν•˜λΌ. ...

March 5, 2020 Β· 2 min Β· Sobamemil
πŸ’» Dev & CSC++ Programming

C++ Programming Ch.3 Exercise 1 Solution

Problem: μ•„λž˜ main()의 Execution Resultκ°€ λ‹€μŒκ³Ό 같도둝 Tower 클래슀λ₯Ό μž‘μ„±ν•˜λΌ. 1 2 3 4 5 6 7 8 9 #include using namespace std; int main() { Tower myTower; // 1 λ―Έν„° Tower seoulTower(100); // 100 λ―Έν„° cout << "λ†’μ΄λŠ” " << myTower.getHeight() << "λ―Έν„°" << endl; cout << "λ†’μ΄λŠ” " << seoulTower.getHeight() << "λ―Έν„°" << endl; } Objective & Hints: 2개의 μƒμ„±μžμ™€ μ—¬λŸ¬ 멀버λ₯Ό κ°€μ§„ 클래슀 λ§Œλ“€κΈ° ...

March 2, 2020 Β· 1 min Β· Sobamemil
πŸ’» Dev & CSC++ Programming

C++ Programming Ch.2 Exercise 12 Solution

Problem: λ‹€μŒ C ν”„λ‘œκ·Έλž¨μ„ C++ ν”„λ‘œκ·Έλž¨μœΌλ‘œ μˆ˜μ •ν•˜μ—¬ μ‹€ν–‰ν•˜λΌ. 이 ν”„λ‘œκ·Έλž¨μ˜ Execution ResultλŠ” Exercise Problem 11κ³Ό κ°™λ‹€. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include <stdio.h> int sum(); int main() { int n=0; printf("끝 수λ₯Ό μž…λ ₯ν•˜μ„Έμš”>>"); scanf("%d", &n); printf("1μ—μ„œ %dκΉŒμ§€μ˜ 합은 %d μž…λ‹ˆλ‹€.\n", n, sum(1,n)); return 0; } int sum(int a, int b) { int k, res=0; for(k=a; k<=b; k++){ res += k; } return res; } 2020/02/28 - [C++/λͺ…ν’ˆ C++ programming] - λͺ…ν’ˆ C++ programming Exercise Problem 2μž₯ 11번 ...

February 28, 2020 Β· 1 min Β· Sobamemil