๐ŸŒˆ๋ช…ํ’ˆ C++ ํ”„๋กœ๊ทธ๋ž˜๋ฐ 3์žฅ๐Ÿง‘โ€๐Ÿ’ป

Se0ng_1lยท2022๋…„ 6์›” 17์ผ
0

๋ช…ํ’ˆCPPํ”„๋กœ๊ทธ๋ž˜๋ฐ

๋ชฉ๋ก ๋ณด๊ธฐ
2/10
post-thumbnail

3์žฅ ์š”์ 

ํด๋ž˜์Šค์™€ ๊ฐ์ฒด

๊ฐ์ฒด

์‹ค์ƒํ™œ์— ์กด์žฌํ•˜๋Š” ๋ชจ๋“  ๊ฒƒ
๋ฉค๋ฒ„ ๋ณ€์ˆ˜์™€ ๋ฉค๋ฒ„ ํ•จ์ˆ˜๋กœ ๊ตฌ์„ฑ๋œ๋‹ค.

ํด๋ž˜์Šค

๊ฐ์ฒด๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ์ •์˜ํ•˜๋Š” ํ‹€, ๊ตฌ์„ฑ๋„
๋ฉค๋ฒ„ ๋ณ€์ˆ˜์™€ ๋ฉค๋ฒ„ ํ•จ์ˆ˜๋ฅผ ์„ ์–ธํ•œ๋‹ค.

<iostream> ์ž…์ถœ๋ ฅ ๊ด€๋ จ ํ—ค๋”ํŒŒ์ผ

์ ‘๊ทผ์ง€์ •์ž : public

ํด๋ž˜์Šค์˜ ๋ฉค๋ฒ„๋ฅผ ์™ธ๋ถ€์— ๊ณต๊ฐœํ•˜์—ฌ ๋‹ค๋ฅธ ํด๋ž˜์Šค๊ฐ€ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•œ๋‹ค.

์ ‘๊ทผ์ง€์ •์ž : private

ํด๋ž˜์Šค ๋‚ด๋ถ€๋ฅผ ์™ธ๋ถ€์—์„œ ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋„๋ก ๋ง‰๋Š”๋‹ค. ๊ธฐ๋ณธ ์ ‘๊ทผ ์ง€์ •์ž

์ ‘๊ทผ์ง€์ •์ž : protected

ํด๋ž˜์Šค ๋‚ด์˜ ๋ฉค๋ฒ„ํ•จ์ˆ˜์™€ ํด๋ž˜์Šค๋ฅผ ์ƒ์†๋ฐ›์€ ํŒŒ์ƒํด๋ž˜์Šค์˜ ๋ฉค๋ฒ„ ํ•จ์ˆ˜์—๊ฒŒ๋งŒ ์ ‘๊ทผ์ด ํ—ˆ์šฉ

#include <iostream>
using namespace std;

class Circle{ // ํด๋ž˜์Šค ์„ ์–ธ
public: // ์ ‘๊ทผ์ง€์ •์ž public
    int radius; // ๋ฉค๋ฒ„๋ณ€์ˆ˜
    double getArea(); // ๋ฉค๋ฒ„ํ•จ์ˆ˜
};

double Circle::getArea() { // ๋ฉค๋ฒ„ํ•จ์ˆ˜ ๊ตฌํ˜„, :: = ์ ‘๊ทผ์ง€์ •์ž
    return 3.14 * radius * radius;
}

int main()
{
    Circle donut; // ๊ฐ์ฒด ์ƒ์„ฑ
    donut.radius = 1; // ๊ฐ์ฒด ๋ฉค๋ฒ„ ๋ณ€์ˆ˜ ์ ‘๊ทผ
    double area = donut.getArea(); // ๊ฐ์ฒด ๋ฉค๋ฒ„ ํ•จ์ˆ˜ ์ ‘๊ทผ
}

์ƒ์„ฑ์ž

๊ฐ์ฒด ์ƒ์„ฑ์‹œ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ํŠน๋ณ„ํ•œ ๋ฉค๋ฒ„ ํ•จ์ˆ˜
ํŠน์ง• :
โ€ƒโ€ƒโ€ƒ์ƒ์„ฑ์ž ํ•จ์ˆ˜๋Š” ํ•œ๋ฒˆ๋งŒ ์ˆ˜ํ–‰๋œ๋‹ค
โ€ƒโ€ƒโ€ƒํ•จ์ˆ˜์˜ ์ด๋ฆ„์€ ํด๋ž˜์Šค ์ด๋ฆ„๊ณผ ๊ฐ™๋‹ค
โ€ƒโ€ƒโ€ƒ๋ฆฌํ„ดํƒ€์ž…์„ ์„ ์–ธํ•˜์ง€ ์•Š๋Š”๋‹ค
โ€ƒโ€ƒโ€ƒ์ค‘๋ณต ๊ฐ€๋Šฅ

๊ธฐ๋ณธ์ƒ์„ฑ์ž

โ€ƒ์ƒ์„ฑ์ž๋ฅผ ์„ ์–ธํ•˜์ง€ ์•Š๋”๋ผ๋„ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์•Œ์•„์„œ ๊ธฐ๋ณธ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
โ€ƒ๋‹จ, ์ƒ์„ฑ์ž๊ฐ€ ํ•˜๋‚˜๋ผ๋„ ์„ ์–ธ๋˜์–ด ์žˆ๋‹ค๋ฉด ์ƒ์„ฑ๋˜์ง€ ์•Š๋Š”๋‹ค.

<cstring> or <string.h> ํ—ค๋”ํŒŒ์ผ 
strcmp, strcpy, strlen ๋“ฑ C๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ•จ์ˆ˜ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ํ—ค๋”ํŒŒ์ผ

<string> ํ—ค๋”ํŒŒ์ผ (string)
c++์—์„œ ์ƒˆ๋กœ ์ถ”๊ฐ€๋œ ๋ฌธ์ž์—ด ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ํ—ค๋”ํŒŒ์ผ

์œ„์ž„์ƒ์„ฑ์ž

๋น„์Šทํ•œ ์ƒ์„ฑ์ž 2๊ฐœ์ค‘ ํ•˜๋‚˜๋ฅผ ๋‹ค๋ฅธ ํ•˜๋‚˜์˜ ์ƒ์„ฑ์ž๋กœ ์œ„์ž„์‹œ์ผœ์„œ ์ด๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๋ฐฉ๋ฒ•

Circle::() : Circle(1){ } // Circle(int r)์˜ ์ƒ์„ฑ์ž ํ˜ธ์ถœ

Circle::() : Circle(int r){
    radius = r;
}

๋ฉค๋ฒ„ ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”

class Point{ // ์ƒ์„ฑ์ž ์ฝ”๋“œ์—์„œ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜ ์ดˆ๊ธฐํ™”
    int x, y;
public:
    Point();
    Point(int a, int b);
};
Point::Point(){ x = 0; y = 0;};
Point::Point(int a, int b){ x = a; y = b;};
// ์ƒ์„ฑ์ž ์„œ๋‘์— ์ดˆ๊นƒ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”
Point::Point() : x(0), y(0){};
Point::Point(int a, int b) : x(a), y(b){};

// ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•
Point::Point(int a) : x(a), y(0){};
Point::Point(int a) : x(a + 100), y(100){};

// ํด๋ž˜์Šค ์„ ์–ธ๋ถ€์—์„œ ์ง์ ‘ ์ดˆ๊ธฐํ™”
class Point{ 
    int x = 0, y = 0;
}

์†Œ๋ฉธ์ž

โ€ƒโ€ƒโ€ƒ๊ฐ์ฒด๊ฐ€ ์†Œ๋ฉธํ•  ๋•Œ ์ˆ˜ํ–‰ํ•  ์ž‘์—…
โ€ƒโ€ƒโ€ƒ์†Œ๋ฉธ์ž๋Š” ๋ฆฌํ„ดํƒ€์ž…์ด ์—†๊ณ  ์–ด๋–ค ๊ฐ’๋„ ๋ฆฌํ„ดํ•ด์„œ๋Š” ์•ˆ๋œ๋‹ค.
โ€ƒโ€ƒโ€ƒ์˜ค์ง ํ•œ๊ฐœ๋งŒ ์กด์žฌ
โ€ƒโ€ƒโ€ƒ๊ธฐ๋ณธ ์ƒ์„ฑ์ž์ฒ˜๋Ÿผ ๊ธฐ๋ณธ ์†Œ๋ฉธ์ž๋„ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋œ๋‹ค.

//์„ ์–ธ ๋ฐฉ๋ฒ•์€ ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ์•ž์— ~๋ถ™์ด๊ธฐ
Circle::~Circle(){}

์ „์—ญ ๊ฐ์ฒด์™€ ์ง€์—ญ ๊ฐ์ฒด ์ƒ์„ฑ๊ณผ ์†Œ๋ฉธ

์ „์—ญ ๊ฐ์ฒด๋Š” ํ”„๋กœ๊ทธ๋žจ ๋กœ๋”ฉ์‹œ ๋ฐ”๋กœ ์ƒ์„ฑ๋˜๊ณ  ์ง€์—ญ๊ฐ์ฒด๋Š” ์ง€์—ญ๊ฐ์ฒด๋Š” ํ•จ์ˆ˜ ์‹คํ–‰์‹œ ์ƒ์„ฑ๋œ๋‹ค.

์†Œ๋ฉธ์€ ํ•จ์ˆ˜๊ฐ€ ๋๋‚ฌ์„๋•Œ ์ง€์—ญ๊ฐ์ฒด๊ฐ€ ์†Œ๋ฉธ๋˜๊ณ  ๋‚˜์ค‘์— ์ „์—ญ๊ฐ์ฒด๊ฐ€ ์†Œ๋ฉธ๋œ๋‹ค.

์ „์—ญ ์ƒ์„ฑ -> ์ง€์—ญ์ƒ์„ฑ -> return -> ์ง€์—ญ์†Œ๋ฉธ -> ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ -> ์ „์—ญ์†Œ๋ฉธ

Tip.

๋ฉค๋ฒ„๋ณ€์ˆ˜๋Š” private์ด ๋ฐ”๋žŒ์งํ•˜๋‹ค, ์ƒ์„ฑ์ž๋Š” public์œผ๋กœ

์ธ๋ผ์ธ ํ•จ์ˆ˜

์ฝ”๋“œ์˜ ํšจ์œจ์„ ์ฆ๊ฐ€ ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์ด์ง€๋งŒ, ์ตœ๊ทผ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์•Œ์•„์„œ ์ธ๋ผ์ธ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋ฉด ํ•ด์ฃผ๋ฏ€๋กœ ๋„˜์–ด๊ฐ„๋‹ค.

๊ตฌ์กฐ์ฒด

C์–ธ์–ด์™€ ๋™์ผํ•˜์ง€๋งŒ, ์ถ”๊ฐ€๋กœ ์ƒ์„ฑ์ž, ์†Œ๋ฉธ์ž์™€ ๊ฐ™์€ ๋ฉค๋ฒ„ํ•จ์ˆ˜๋„ ์„ ์–ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๋ฐ”๋žŒ์งํ•œ C++ ํ”„๋กœ๊ทธ๋žจ ์ž‘์„ฑ๋ฒ•

ํ—ค๋” ํŒŒ์ผ๊ณผ CPPํŒŒ์ผ ๋ถ„๋ฆฌํ•œ๋‹ค.

ํ—ค๋”ํŒŒ์ผ = ํด๋ž˜์Šค์˜ ์„ ์–ธ

ํ—ค๋”ํŒŒ์ผ ๊ด€๋ จ CPPํŒŒ์ผ = ํด๋ž˜๊ทธ ๊ตฌํ˜„

main.cppํŒŒ์ผ = mainํ•จ์ˆ˜ ๋“ฑ ๋‚˜๋จธ์ง€ ์ฝ”๋“œ

ํ—ค๋”ํŒŒ์ผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ• #include "ํ—ค๋”ํŒŒ์ผ์ด๋ฆ„.h"

๋ฌธ์ œ์  : ํ—ค๋”ํŒŒ์ผ ์ค‘๋ณต

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• : ํ—ค๋”ํŒŒ์ผ์— ์กฐ๊ฑด ์ปดํŒŒ์ผ๋ฌธ ์ถ”๊ฐ€

#ifndef (์กฐ๊ฑด ์ปดํŒŒ์ผ๋ฌธ์˜ ์ƒ์ˆ˜)
#define (์กฐ๊ฑด ์ปดํŒŒ์ผ๋ฌธ์˜ ์ƒ์ˆ˜)

class abc{
     . . . .
}

#endif

๋ช…ํ’ˆ C++ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ฑ…
https://book.naver.com/bookdb/book_detail.naver?bid=13395206

โš ๏ธ ์ฃผ์˜ โš ๏ธ
1. ์—ฌ๊ธฐ์„œ๋ถ€ํ„ฐ๋Š” ์‹ค์Šต๋ฌธ์ œ ์ •๋‹ต์ž…๋‹ˆ๋‹ค.
2.์ œ๊ฐ€ ์ž‘์„ฑํ•œ ์ •๋‹ต์ด ํ‹€๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ˜น์‹œ ํ‹€๋ฆฐ๊ฒŒ ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€๋กœ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํžˆ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
3. C++๋ฅผ ๊ณต๋ถ€ํ•˜์‹œ๋Š” ํ•™์ƒ์ด์‹œ๋ผ๋ฉด ๋ณด์‹œ๊ธฐ ์ „์— ์ง์ ‘ ๊ผญ ํ•œ ๋ฒˆ ํ’€์–ด๋ณด์„ธ์š”!

์‹ค์Šต ๋ฌธ์ œ 3 - 1
๋ฌธ์ œ : ์•„๋ž˜ ์ถœ๋ ฅ์ด ๋‚˜์˜ค๋„๋ก Towerํด๋ž˜์Šค ์ž‘์„ฑํ•˜๊ธฐ

#include <iostream>

using namespace std;

int main()
{
    Tower myTower;
    Tower seoulTower(100);
    cout << "๋†’์ด๋Š” " << myTower.getHeight() << "๋ฏธํ„ฐ" << endl;
    cout << "๋†’์ด๋Š” " << seoulTower.getHeight() << "๋ฏธํ„ฐ" << endl;
}
#include <iostream>

using namespace std;

class Tower{
    int height;
public:
    Tower();
    Tower(int height);
    int getHeight();
};

Tower::Tower() : height(1) {}
Tower::Tower(int height) :height(height){}

int Tower::getHeight()
{
    return height;
}

int main()
{
    Tower myTower;
    Tower seoulTower(100);
    cout << "๋†’์ด๋Š” " << myTower.getHeight() << "๋ฏธํ„ฐ" << endl;
    cout << "๋†’์ด๋Š” " << seoulTower.getHeight() << "๋ฏธํ„ฐ" << endl;
}

์‹ค์Šต ๋ฌธ์ œ 3 - 2
๋ฌธ์ œ : ์•„๋ž˜ ์ถœ๋ ฅ์ด ๋‚˜์˜ค๋„๋ก Dateํด๋ž˜์Šค ์ž‘์„ฑํ•˜๊ธฐ

#include <iostream>
using namespace std;

int main()
{
    Date birth(2014, 3, 20);
    Date independencyDay("1945/8/15");
    independencyDay.show();
    cout << birth.getYear() << ',' << birth.getMonth() << ',' << birth.getDay() << endl;
}
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

class Date{
    int year;
    int month;
    int day;
    string date;
public :
    Date(int a, int b, int c);
    Date(string date);
    int getYear();
    int getMonth();
    int getDay();
    void show();
};
Date::Date(int a, int b, int c) {
    year = a;
    month = b;
    day = c;
}
Date::Date(string date) {
    char temp[100];
    strcpy(temp, date.c_str());
    year = stoi(strtok(temp, "/"));
    month = stoi(strtok(nullptr, "/"));
    day = stoi(strtok(nullptr, "/"));
}

int Date::getYear() {return year;}
int Date::getMonth() {return month;}
int Date::getDay() {return day;}
void Date::show() {cout << year << "๋…„" << month << "์›”" << day << "์ผ" << endl;}

int main()
{
    Date birth(2014, 3, 20);
    Date independencyDay("1945/8/15");
    independencyDay.show();
    cout << birth.getYear() << ',' << birth.getMonth() << ',' << birth.getDay() << endl;
}

c_str : stringํ˜•์˜ ๋ฌธ์ž์—ด์€ char ๋ฐฐ์—ด์˜ ๋ฌธ์ž์—ด๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.
strtok : ๋ฌธ์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฌธ์ž ์ž๋ฅด๋Š” ํ•จ์ˆ˜, cstring ํ—ค๋”ํŒŒ์ผ

strtok(๋ฌธ์ž์—ด์ด ๋“ค์–ด์žˆ๋Š” ๋ฐฐ์—ด(ํฌ์ธํ„ฐ), ๊ตฌ๋ถ„์ž)

nullptr์„ ๋„ฃ์€ ์ด์œ ?

  1. strtok๋Š” ๋ฌธ์ž์—ด์—์„œ ๊ตฌ๋ถ„์ž๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด ํ•ด๋‹น ๊ตฌ๋ถ„์ž๋ฅผ null๊ฐ’์œผ๋กœ ๋ฐ”๊พธ๊ณ  ๊ตฌ๋ถ„์ž ์ „์— ๋ฌธ์ž์—ด ํฌ์ธํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

  2. nullptr์„ ๋งŒ๋‚˜๊ฒŒ ๋˜๋ฉด ์ด์ „์— ๋ฌธ์ž์—ด์—์„œ null๊ฐ’์˜ ๋‹ค์Œ ๋ฌธ์ž์—ด๋ถ€ํ„ฐ ๊ตฌ๋ถ„์ž๊นŒ์ง€ ๊ฒ€์‚ฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ณ  ํฌ์ธํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

  3. ๋”ฐ๋ผ์„œ ํ•ด๋‹น ๋ฌธ์ž์—ด์—์„œ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฝ‘์•„๋‚ด๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค.

  4. strtok๋ฅผ ์‚ฌ์šฉํ•œ ํ•จ์ˆ˜์˜ ๋ฌธ์ž์—ด์€ ์œ„์™€ ๊ฐ™์ด ๊ตฌ๋ถ„์ž๊ฐ€ null๋กœ ๋ฐ”๋€๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

์‹ค์Šต ๋ฌธ์ œ 3 - 3
๋ฌธ์ œ : Accountํด๋ž˜์Šค ๋งŒ๋“ค๊ธฐ
๊ณ„์ขŒ์ฃผ์ธ, ๊ณ„์ขŒ๋ฒˆํ˜ธ, ์ž”์•ก์„ ๋‚˜ํƒ€๋‚ด๋Š” 3๊ฐœ์˜ ๋ฉค๋ฒ„๋ณ€์ˆ˜๋กœ ๊ตฌ์„ฑ

#include <iostream>
using namespace std;

class Account{
    string m_name;
    int m_accountNum;
    int m_money;
public :
    Account(string name, int accountNum, int money)
    {
        m_name = name;
        m_accountNum = accountNum;
        m_money = money;
    }
    void deposit(int a)
    {
        m_money += a;
    }
    int withdraw(int a)
    {
        m_money -= a;
        return m_money;
    }
    string getOwner()
    {
        return m_name;
    }
    int inquiry()
    {
        return m_money;
    }
};

int main()
{
    Account a("kitae", 1, 5000);
    a.deposit(50000);
    cout << a.getOwner() << "์˜ ์ž”์•ก์€ " << a.inquiry() << endl;
    int money = a.withdraw(20000);
    cout << a.getOwner() << "์˜ ์ž”์•ก์€ " << a.inquiry() << endl;
}

์‹ค์Šต ๋ฌธ์ œ 3 - 4
๋ฌธ์ œ :

์ปคํ”ผ ๋จธ์‹  ํด๋ž˜์Šค ๋งŒ๋“ค๊ธฐ

์—์Šคํ”„๋ ˆ์†Œ ํ•œ์ž” = ์ปคํ”ผ, ๋ฌผ ๊ฐ๊ฐ 1์”ฉ ์†Œ๋น„

์•„๋ฉ”๋ฆฌ์นด๋…ธ ํ•œ์ž” = ์ปคํ”ผ 1, ๋ฌผ 2 ์†Œ๋น„

์„คํƒ•์ปคํ”ผ ํ•œ์ž” = ์ปคํ”ผ 1, ๋ฌผ 2, ์„คํƒ• 1 ์†Œ๋น„

#include <iostream>
using namespace std;

int main()
{
    CoffeeMachine java(5, 10, 3);
    java.drinkEspresso();
    java.show();
    java.drinkAmericano();
    java.show();
    java.drinkSugarCoffee();
    java.show();
    java.fill();
    java.show();
}
#include <iostream>
using namespace std;

class CoffeeMachine{
    int m_coffee;
    int m_water;
    int m_sugar;
public :
    CoffeeMachine(int coffee, int water, int sugar) : m_coffee(coffee), m_sugar(sugar), m_water(water){}
    void drinkEspresso(){m_coffee -= 1;m_water -= 1;}
    void drinkAmericano(){m_coffee -= 1;m_water -= 2;}
    void drinkSugarCoffee(){m_coffee -= 1;m_water -= 2;m_sugar -= 1;}
    void show(){cout << "์ปคํ”ผ ๋จธ์‹  ์ƒํƒœ, ์ปคํ”ผ:" << m_coffee << " ๋ฌผ:" << m_water << " ์„คํƒ•:" << m_sugar << endl;}
    void fill(){m_coffee = 10;m_water = 10;m_sugar = 10;}
};
int main()
{
    CoffeeMachine java(5, 10, 3);
    java.drinkEspresso();
    java.show();
    java.drinkAmericano();
    java.show();
    java.drinkSugarCoffee();
    java.show();
    java.fill();
    java.show();
}

์‹ค์Šต ๋ฌธ์ œ 3 - 5
๋ฌธ์ œ : ๋‚œ์ˆ˜ ๋ฐœ์ƒ์‹œํ‚ค๋Š” Randomํด๋ž˜์Šค ๋งŒ๋“ค๊ธฐ

  1. 0 ~ 32767๊นŒ์ง€์˜ ๋žœ๋คํ•œ ์ •์ˆ˜ 10๊ฐœ ์ถœ๋ ฅํ•˜๊ธฐ

  2. 2 ~ 4๊นŒ์ง€์˜ ๋žœ๋คํ•œ ์ •์ˆ˜ 10๊ฐœ ์ถœ๋ ฅํ•˜๊ธฐ

C++์—์„œ ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ

// ์ถœ์ฒ˜ : https://docs.microsoft.com/ko-kr/cpp/standard-library/random?view=msvc-170
#include <random>
#include <iostream>

using namespace std;

int main()
{
    random_device rd;   // ์‹œ๋“œ ์ƒ์„ฑ๊ธฐ
    mt19937 gen(rd());  // ์‹œ๋“œ ์ƒ์„ฑ๊ธฐ ์ดˆ๊ธฐํ™”
    uniform_int_distribution<> dist(1,6); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ

    for (int i = 0; i < 5; ++i) {
        cout << dist(gen) << " "; // ๋‚œ์ˆ˜ ์ƒ์„ฑ ๋ฐ ์ถœ๋ ฅ
    }
    cout << endl;
}

C์–ธ์–ด ์Šคํƒ€์ผ ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ

#include <iostream>
#include <cstdlib> // rand()
#include <ctime> // time()
using namespace std;

int main()
{
	srand(time(nullptr)); // time์„ ์ด์šฉํ•œ ์‹œ๋“œ๋ณ€๊ฒฝ, ๋งค๋ฒˆ ๋‹ค๋ฅธ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๊ฒŒ ํ•ด์ค€๋‹ค.
	int random = 0; // ์ •์ˆ˜ํ˜• ๋ณ€์ˆ˜ ์„ ์–ธ
	for (int i = 0; i < 10; i++) {
		random = rand()%9; // rand() ๋‚œ์ˆ˜ ๋ฐœ์ƒ, %9 = 0 ~ 9๊นŒ์ง€์˜ ์ •์ˆ˜๋ฒ”์œ„๋ฅผ ์œ„ํ•ด
		cout << random << endl;
	}
}

C++

#include <iostream>
#include <cstdlib>
#include <random>
using namespace std;

class Random{
private:
    mt19937 gen;
public:
    Random() : gen((std::random_device())()){ }
    int next()
    {
        uniform_int_distribution<> dist(0,RAND_MAX); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        return dist(gen);
    }
    int nextInRange(int a, int b)
    {
        uniform_int_distribution<> dist(a, b); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        return dist(gen);
    }
};

int main()
{
    Random r;
    cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.next() % 32768; // ๋‚ด ์ปดํŒŒ์ผ๋Ÿฌ์—์„œ๋Š” RAND_MAX๊ฐ’์ด 2147483647์ด๋ผ์„œ %์—ฐ์‚ฐ์„ ํ†ตํ•ด ๋ฒ”์œ„ ์ง€์ •
        cout << n << ' ';
    }
    cout << endl << endl << "-- 2์—์„œ " << "4 ๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.nextInRange(2, 4);
        cout << n << ' ';
    }
    cout << endl;
}

C์–ธ์–ด ์Šคํƒ€์ผ

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class Random{
public:
    Random();
    int next();
    int nextInRange(int a, int b);
};
Random::Random() {
    srand((unsigned int)time(NULL));
}
int Random::next() {
    return rand();
}
int Random::nextInRange(int a, int b) {
    return rand() % 3 + 2;

}

int main()
{
    Random r;
    cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.next();
        cout << n << ' ';
    }
    cout << endl << endl << "-- 2์—์„œ " << "4 ๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.nextInRange(2, 4);
        cout << n << ' ';
    }
    cout << endl;
}

์‹ค์Šต ๋ฌธ์ œ 3 - 6
๋ฌธ์ œ : ๋ฌธ์ œ 5๋ฒˆ ์ฐธ๊ณ ํ•ด์„œ ์ง์ˆ˜ ๋žœ๋ค ์ •์ˆ˜๋งŒ ์ถœ๋ ฅํ•˜๋Š” EvenRandomํด๋ž˜์Šค ๋งŒ๋“ค๊ธฐ, 0๋„ ์ง์ˆ˜๋กœ ์ฒ˜๋ฆฌ

C++

#include <iostream>
#include <cstdlib>
#include <random>
using namespace std;

class EvenRandom{
private:
    mt19937 gen;
public:
    EvenRandom() : gen((std::random_device())()){ }
    int next()
    {
        uniform_int_distribution<> dist(0,RAND_MAX); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        while(true)
        {
            int n = dist(gen);
            if(n % 2 == 0)
                return n;
        }
    }
    int nextInRange(int a, int b)
    {
        uniform_int_distribution<> dist(a, b); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        while(true)
        {
            int n = dist(gen);
            if(n % 2 == 0)
                return n;
        }
    }
};

int main()
{
    EvenRandom r;
    cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.next();
        cout << n << ' ';
    }
    cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.nextInRange(2, 10);
        cout << n << ' ';
    }
    cout << endl;
}

C์–ธ์–ด ์Šคํƒ€์ผ

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class EvenRandom{
public:
    EvenRandom();
    int next();
    int nextInRange(int a, int b);
};
EvenRandom::EvenRandom() {
    srand((unsigned int)time(NULL));
}
int EvenRandom::next() {
    while(true)
    {
        int n = rand();
        if(n % 2 == 0)
            return n;
    }
}
int EvenRandom::nextInRange(int a, int b) {
    while(true)
    {
        int n = rand();
        if(n % 2 == 0)
            return n % 5 * 2 + 2;
    }
}

int main()
{
    EvenRandom r;
    cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.next();
        cout << n << ' ';
    }
    cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
    for(int i = 0; i < 10; i++)
    {
        int n = r.nextInRange(2, 10);
        cout << n << ' ';
    }
    cout << endl;
}

์‹ค์Šต ๋ฌธ์ œ 3 - 7
๋ฌธ์ œ : ๋‚œ์ˆ˜๋ฅผ ํ™€์ˆ˜๋กœ ํ• ์ง€ ์ง์ˆ˜๋กœ ํ• ์ง€ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” SelectableRandomํด๋ž˜์Šค ์ƒ์„ฑํ•˜๊ธฐ

C++

#include <iostream>
#include <cstdlib>
#include <random>
using namespace std;

class SelectableRandom{
private:
    mt19937 gen;
public:
    SelectableRandom() : gen((std::random_device())()){ }
    void next(int chkOddEven)
    {
        uniform_int_distribution<> dist(0,RAND_MAX); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        if(chkOddEven == 1)
        {
            cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ํ™€์ˆ˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
            for(int i = 0; i < 10; i++)
            {
                while(true)
                {
                    int n = dist(gen);
                    if(n % 2 != 0)
                    {
                        cout << n << ' ';
                        break;
                    }
                }
            }
        }
        else if(chkOddEven == 2)
        {
            cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ์ง์ˆ˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
            for(int i = 0; i < 10; i++)
            {
                while(true)
                {
                    int n = dist(gen);
                    if(n % 2 == 0)
                    {
                        cout << n << ' ';
                        break;
                    }
                }
            }
        }
    }
    void nextInRange(int a, int b, int chkOddEven)
    {
        uniform_int_distribution<> dist(a, b); // 1 ~ 6๋ฒ”์œ„์— ๋‚œ์ˆ˜ ๋งŒ๋“ค๊ธฐ, ํ™•๋ฅ  ๋ชจ๋‘ ๋™์ผ
        if(chkOddEven == 1)
        {
            cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ํ™€์ˆ˜ ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
            for(int i = 0; i < 10; i++)
            {
                while(true)
                {
                    int n = dist(gen);
                    if(n % 2 != 0)
                    {
                        cout << n << ' ';
                        break;
                    }
                }
            }
        }
        else if(chkOddEven == 2)
        {
            cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ์ง์ˆ˜ ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
            for(int i = 0; i < 10; i++)
            {
                while(true)
                {
                    int n = dist(gen);
                    if(n % 2 == 0)
                    {
                        cout << n << ' ';
                        break;
                    }
                }
            }
        }
    }
};

int main()
{
    // chkOddEven๊ฐ’์ด 1์ด๋ฉด ํ™€์ˆ˜ ์ถœ๋ ฅ 2๋ฉด ์ง์ˆ˜์ถœ๋ ฅ
    SelectableRandom r;
    r.next(1);
    cout << endl << endl;
    r.next(2);
    r.nextInRange(2, 10, 1);
    r.nextInRange(2, 10, 2);
}

C์–ธ์–ด ์Šคํƒ€์ผ

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class SelectableRandom{
public:
    SelectableRandom();
    void next(int chkOddEven);
    void nextInRange(int a, int b, int chkOddEven);
};
SelectableRandom::SelectableRandom() {
    srand((unsigned int)time(NULL));
}
void SelectableRandom::next(int chkOddEven) {
    if(chkOddEven == 1)
    {
        cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ํ™€์ˆ˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
        for(int i = 0; i < 10; i++)
        {
            while(true)
            {
                int n = rand();
                if(n % 2 != 0)
                {
                    cout << n << ' ';
                    break;
                }
            }
        }
    }
    else if(chkOddEven == 2)
    {
        cout << "-- 0์—์„œ " << RAND_MAX << "๊นŒ์ง€์˜ ์ง์ˆ˜ ๋žœ๋ค ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
        for(int i = 0; i < 10; i++)
        {
            while(true)
            {
                int n = rand();
                if(n % 2 == 0)
                {
                    cout << n << ' ';
                    break;
                }
            }
        }
    }
}
void SelectableRandom::nextInRange(int a, int b, int chkOddEven) {
    if(chkOddEven == 1)
    {
        cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ํ™€์ˆ˜ ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
        for(int i = 0; i < 10; i++)
        {
            cout << rand() % 4 * 2 + 3 << ' ';
        }
    }
    else if(chkOddEven == 2)
    {
        cout << endl << endl << "-- 2์—์„œ " << "10 ๊นŒ์ง€์˜ ๋žœ๋ค ์ง์ˆ˜ ์ •์ˆ˜ 10 ๊ฐœ--" << endl;
        for(int i = 0; i < 10; i++)
        {
            while(true)
            {
                int n = rand();
                if(n % 2 == 0)
                {
                    cout << (n % 5 + 1) * 2 << ' ';
                    break;
                }
            }
        }
    }
}

int main()
{
    SelectableRandom r;
    r.next(1);
    cout << endl << endl;
    r.next(2);
    r.nextInRange(2, 10, 1);
    r.nextInRange(2, 10, 2);
}
  

์‹ค์Šต ๋ฌธ์ œ 3 - 8
๋ฌธ์ œ : ์†Œ์ˆ˜์ ์„ ๊ฐ€์ง€๋Š” 5๊ฐœ์˜ ์‹ค์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ ์ œ์ผ ํฐ ์ˆ˜๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋ผ

#include <iostream>
#include <string>
using namespace std;

int main()
{
    Integer n(30);
    cout << n.get() << ' ';
    n.set(50);
    cout << n.get() << ' ';

    Integer m("300");
    cout << m.get() << ' ';
    cout << m.isEven();
}

#include <iostream>
#include <string>
using namespace std;

class Integer{
    int m_n;
public:
    Integer(int n) : m_n(n){}
    Integer(string n)
    {
        m_n = stoi(n);
    }
    int get()
    {
        return m_n;
    }
    void set(int n)
    {
        m_n = n;
    }
    bool isEven()
    {
        return (m_n % 2 == 0);
    }
};
int main()
{
    Integer n(30);
    cout << n.get() << ' ';
    n.set(50);
    cout << n.get() << ' ';

    Integer m("300");
    cout << m.get() << ' ';
    cout << m.isEven();
}

์‹ค์Šต ๋ฌธ์ œ 3- 9
๋ฌธ์ œ : ์‚ฌ๊ฐํ˜•์— ๋‚ด์ ‘ํ•˜๋Š” ํƒ€์›์„ ์ถ”์ƒํ™”ํ•œ Oval ํด๋ž˜์Šค ์„ ์–ธ๋ถ€์™€ ๊ตฌํ˜„๋ถ€๋กœ ๋‚˜๋ˆ„์–ด ๋งŒ๋“ค๊ธฐ

oval.h

#ifndef INFC___OVAL_H
#define INFC___OVAL_H
class Oval{
private:
    int width, height;
public:
    Oval();
    Oval(int w, int h);
    ~Oval();
    int getWidth();
    int getHeight();
    void set(int w, int h);
    void show();
};
#endif //INFC___OVAL_H

oval.cpp

#include "oval.h"
#include <iostream>
Oval::Oval() : width(1), height(1){}
Oval::Oval(int w, int h) : width(w), height(h){}
Oval::~Oval(){std::cout << "Oval์†Œ๋ฉธ : width = " << width << ", height = " << height << std::endl;}

int Oval::getWidth() {return width;}
int Oval::getHeight() {return height;}
void Oval::set(int w, int h) {width = w; height = h;}
void Oval::show() {std::cout <<  "width = " << width << ", height = " << height << std::endl;}

main.cpp

#include <iostream>
#include "oval.h"
using namespace std;

int main()
{
    Oval a, b(3, 4);
    a.set(10, 20);
    a.show();
    cout << b.getWidth() << ", " << b.getHeight() << endl;
}

์‹ค์Šต ๋ฌธ์ œ 3 - 10
๋ฌธ์ œ : Add, Sub, Mul, Div 4๊ฐœ์˜ ์‚ฌ์น™์—ฐ์‚ฐ ํด๋ž˜์Šค ๋งŒ๋“ค๊ธฐ

Calculator.h

#ifndef INFC___CALCULATOR_H
#define INFC___CALCULATOR_H
class Add{
    int m_a, m_b;
public:
    ~Add();
    void setValue(int a, int b);
    int calculate();
};
class Sub{
    int m_a, m_b;
public:
    ~Sub();
    void setValue(int a, int b);
    int calculate();
};
class Mul{
    int m_a, m_b;
public:
    ~Mul();
    void setValue(int a, int b);
    int calculate();
};
class Div{
    int m_a, m_b;
public:
    ~Div();
    void setValue(int a, int b);
    int calculate();
};

#endif //INFC___CALCULATOR_H

Calculator.cpp

#include "calculator.h"

Add::~Add() {}
Sub::~Sub() {}
Mul::~Mul() {}
Div::~Div() {}

void Add::setValue(int a, int b) {m_a = a; m_b = b;}
void Sub::setValue(int a, int b) {m_a = a; m_b = b;}
void Mul::setValue(int a, int b) {m_a = a; m_b = b;}
void Div::setValue(int a, int b) {m_a = a; m_b = b;}

int Add::calculate() {return m_a + m_b;}
int Sub::calculate() {return m_a - m_b;}
int Mul::calculate() {return m_a * m_b;}
int Div::calculate() {return m_a / m_b;}

main.cpp

#include <iostream>
#include "calculator.h"
using namespace std;

int main()
{
    while(true)
    {
        int a, b;
        char op;
        cout << "๋‘ ์ •์ˆ˜์™€ ์—ฐ์‚ฐ์ž๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”>>";
        cin >> a >> b >> op;

        if(op == '+')
        {
            Add temp;
            temp.setValue(a, b);
            cout << temp.calculate() << endl;
        }
        else if(op == '-')
        {
            Sub temp;
            temp.setValue(a, b);
            cout << temp.calculate() << endl;
        }
        else if(op == '*')
        {
            Mul temp;
            temp.setValue(a, b);
            cout << temp.calculate() << endl;
        }
        else if(op == '/')
        {
            Div temp;
            temp.setValue(a, b);
            cout << temp.calculate() << endl;
        }
    }
}

์‹ค์Šต ๋ฌธ์ œ 3 - 11
๋ฌธ์ œ : ์ฃผ์–ด์ง„ ์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  Box.cpp, Box.h, main.cpp๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ

#include <iostream>
using namespace std;

class Box{
    int width, height;
    char fill;
public:
    Box(int w, int h) {setSize(w, h); fill = '*';}
    void setFill(char f) {fill = f;}
    void setSize(int w, int h) {width = w; height = h;}
    void draw();
};
void Box::draw() {
    for(int n = 0; n < height; n++)
    {
        for(int m = 0; m < width; m++)
            cout << fill;
        cout << endl;
    }
}

int main()
{
    Box b(10, 2);
    b.draw();
    cout << endl;
    b.setSize(7, 4);
    b.setFill('^');
    b.draw();
}

Box.h

#ifndef INFC___BOX_H
#define INFC___BOX_H
class Box{
    int width, height;
    char fill;
public:
    Box(int w, int h);
    void setFill(char f);
    void setSize(int w, int h);
    void draw();
};
#endif //INFC___BOX_H

Box.cpp

#include "Box.h"
#include <iostream>

Box::Box(int w, int h) {setSize(w, h); fill = '*';}
void Box::setFill(char f) {fill = f;}
void Box::setSize(int w, int h) {width = w; height = h;}
void Box::draw() {
    for(int n = 0; n < height; n++)
    {
        for(int m = 0; m < width; m++)
            std::cout << fill;
        std::cout << std::endl;
    }
}

main.cpp

#include <iostream>
#include "Box.h"
using namespace std;

int main()
{
    Box b(10, 2);
    b.draw();
    cout << endl;
    b.setSize(7, 4);
    b.setFill('^');
    b.draw();
}

์‹ค์Šต ๋ฌธ์ œ 3 - 12
๋ฌธ์ œ : ์ฃผ์–ด์ง„ ์ถœ๋ ฅ๊ณผ ์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  Ram.cpp, Ram.h, Ram.cpp๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ

#include <iostream>
using namespace std;

class Ram{
    char mem[100 * 1024];
    int size;
public:
    Ram();
    ~Ram();
    char read(int address);
    void write(int address, char value);
};

int main()
{
    Ram ram;
    ram.write(100, 20);
    ram.write(101, 30);
    char res = ram.read(100) + ram.read(101);
    ram.write(102, res);
    cout << "102 ๋ฒˆ์ง€์˜ ๊ฐ’ = " << (int)ram.read(102) << endl;
}

Ram.h

#ifndef INFC___RAM_H
#define INFC___RAM_H
class Ram{
    char mem[100 * 1024];
    int size;
public:
    Ram();
    ~Ram();
    char read(int address);
    void write(int address, char value);
};
#endif //INFC___RAM_H

Ram.cpp

#include "Ram.h"
#include <iostream>

Ram::Ram() {
    size = 100 * 1024;
    for(int i = 0; i < size; i++)
    {
        mem[i] = 0;
    }
}
Ram::~Ram() {
    std::cout << "๋ฉ”๋ชจ๋ฆฌ ์ œ๊ฑฐ๋จ" << std::endl;
}
void Ram::write(int address, char value) {
    mem[address] = value;
}

char Ram::read(int address) {
    return mem[address];
}

main.cpp

#include <iostream>
#include "Ram.h"
using namespace std;


int main()
{
    Ram ram;
    ram.write(100, 20);
    ram.write(101, 30);
    char res = ram.read(100) + ram.read(101);
    ram.write(102, res);
    cout << "102 ๋ฒˆ์ง€์˜ ๊ฐ’ = " << (int)ram.read(102) << endl;

}
profile
์น˜ํƒ€๊ฐ€ ๋˜๊ณ  ์‹ถ์€ ์ทจ์ค€์ƒ

0๊ฐœ์˜ ๋Œ“๊ธ€