#include <iostream>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
/*
//318p NO.09
class Board{
static string *text;
static int num;
public:
static void add(string s){
text[num]= s;
num++;
}
static void print(){
cout<< "********** 게시판입니다. **********"<<endl;
for(int i=0; i<num; i++)
cout<<i<< ":" << text[i]<<endl;
}
};
int Board::num=0;
string *Board::text = new string[100];
int main()
{
Board::add("중간고사는 감독 없는 자율 시험입니다.");
Board::add("코딩 라운지 많이 이용해 주세요.");
Board::print();
Board::add("진소린 학생이 경진대회 입상하였습니다. 축하해주세요");
Board::print();
}
*/
/*
//322p NO.7-1
class Rect;
bool equals(Rect r, Rect s);
class Rect{
int width, height;
public:
Rect(int width, int height){this->width = width; this -> height = height;}
friend bool equals(Rect r, Rect s);
};
bool equals(Rect r, Rect s) {
if(r.width == s.width && r.height == s.height) return true;
else return false;
}
int main() {
Rect a(3,4), b(4,5);
if(equals(a,b)) cout<< "equal" << endl;
else cout << "not equal" << endl;
}
*/
/*
//324p NO.7-2
class Rect;
class RectManager{
public:
bool equals(Rect r, Rect s);
};
class Rect{
int width, height;
public:
Rect(int width, int height) {this->width= width; this->height = height;}
friend bool RectManager::equals(Rect r, Rect s);
};
bool RectManager::equals(Rect r, Rect s) {
if(r.width == s.width && r.height == s.height) return true;
else return false;
}
int main() {
Rect a(3,4), b(3,4);
RectManager man;
if(man.equals(a,b)) cout<< "equal"<<endl;
else cout<< "not equal" << endl;
}
*/
/*
//325p NO.7-3
class Rect;
class RectManager{
public:
bool equals(Rect r, Rect s);
void copy(Rect& dest, Rect& src);
};
class Rect{
int width, height;
public:
Rect(int width, int height) {this->width=width; this->height=height; }
friend RectManager;
};
bool RectManager::equals(Rect r, Rect s){
if(r.width == s.width && r.height == s.height) return true;
else return false;
}
void RectManager::copy(Rect& dest, Rect& src){
dest.width = src.width; dest.height = src.height;
}
int main(){
Rect a(3,4), b(5,6);
RectManager man;
man.copy(b,a);
if(man.equals(a,b)) cout<< "equal"<< endl;
else cout<< "not equal" << endl;
}
*/
/*
//335p NO.7-4
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power operator+ (Power op2);
};
void Power::show(){
cout<< "kick=" <<kick<< ',' << "punch="<< punch<< endl;
}
Power Power:: operator+(Power op2){
Power tmp;
tmp.kick = this-> kick + op2.kick;
tmp.punch = this->punch + op2.punch;
return tmp;
}
int main() {
Power a(3,5), b(4,6), c;
c = a+b;
a.show();
b.show();
c.show();
}
*/
/*
//337p NO.7-5
class Power{
int kick;
int punch;
public:
Power (int kick=0, int punch=0) {this->kick=kick; this->punch=punch;}
void show();
bool operator == (Power op2);
};
void Power::show(){
cout<< "kick= " << kick<< ',' << "punch= "<< punch << endl;
}
bool Power::operator==(Power op2){
if(kick==op2.kick && punch==op2.punch) return true;
else return false;
}
int main(){
Power a(3,5), b(3,5);
a.show();
b.show();
if(a == b) cout<< "두 파워가 같다." << endl;
else cout<< "두 파워가 같지 않다."<< endl;
}
*/
/*
//339p NO.7-6
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power& operator+=(Power op2);
};
void Power::show(){
cout<<"kick= " << kick << ',' << "punch= " << punch<< endl;
}
Power&Power::operator+=(Power op2){
kick=kick + op2.kick;
punch=punch + op2.punch;
return *this;
}
int main(){
Power a(3,5), b(4,6), c;
a.show();
b.show();
c=a+=b;
a.show();
c.show();
}
*/
/*
//341p NO.7-7
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power operator+ (int op2);
};
void Power::show() {
cout<<"kick= "<< kick<< ',' << "punch= " <<punch<<endl;
}
Power Power::operator+(int op2){
Power tmp;
tmp.kick = kick + op2;
tmp.punch = punch +op2;
return tmp;
}
int main(){
Power a(3,5), b;
a.show();
b.show();
b= a+2;
a.show();
b.show();
}
*/
/*
//344p NO.7-8
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power& operator++ ();
};
void Power::show(){
cout<<"kick= "<< kick << ',' << "punch= "<< punch<< endl;
}
Power&Power::operator++(){
kick++;
punch++;
return *this;
}
int main(){
Power a(3,5), b;
a.show();
b.show();
b= ++a;
a.show();
b.show();
}
*/
/*
//345p NO.7-9
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick =kick; this->punch=punch;
}
void show();
bool operator! ();
};
void Power::show(){
cout<<"kick= "<< kick << ',' << "punch= " << punch << endl;
}
bool Power::operator!(){
if(kick == 0 && punch ==0) return true;
else return false;
}
int main() {
Power a(0,0), b(5,5);
if(!a) cout<<"a의 파워가 0이다." <<endl;
else cout << "a의 파워가 0이 아니다." << endl;
if(!b) cout << "b의 파워가 0이다."<< endl;
else cout<< "b의 파워가 0이 아니다."<<endl;
}
*/
/*
//347p NO.7-10
class Power {
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power operator++ (int x);
};
void Power::show() {
cout<< "kick= "<< kick << ',' << "punch= "<< punch << endl;
}
Power Power:: operator++(int x){
Power tmp = *this;
kick++;
punch++;
return tmp;
}
int main(){
Power a(3,5), b;
a.show();
b.show();
b=a++;
a.show();
b.show();
}
*/
/*
//351p NO.7-11
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
friend Power operator+(int op1, Power op2);
};
void Power::show() {
cout<< "kick= "<<kick<<','<<"punch= "<< punch<<endl;
}
Power operator+(int op1, Power op2){
Power tmp;
tmp.kick =op1+op2.kick;
tmp.punch=op1+op2.punch;
return tmp;
}
int main(){
Power a(3,5), b;
a.show();
b.show();
b=2+a;
a.show();
b.show();
}
*/
/*
//353p NO.7-12
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
friend Power operator+(Power op1, Power op2);
};
void Power::show(){
cout<<"kick= " << kick << ',' <<"punch= " << punch<< endl;
}
Power operator+(Power op1, Power op2){
Power tmp;
tmp.kick=op1.kick+op2.kick;
tmp.punch=op1.punch+op2.punch;
return tmp;
}
int main() {
Power a(3,5), b(4,6), c;
c=a+b;
a.show();
b.show();
c.show();
}
*/
/*
//355p NO.7-13
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0) { this->kick=kick; this->punch=punch;}
void show();
friend Power& operator++(Power& op);
friend Power operator++(Power& op, int x);
};
void Power::show(){
cout<< "kick= " << kick << ',' << "punch= " << punch<< endl;
}
Power& operator++(Power& op){
op.kick++;
op.punch++;
return op;
}
Power operator++(Power& op, int x){
Power tmp=op;
op.kick++;
op.punch++;
return tmp;
}
int main(){
Power a(3,5), b;
b=++a;
a.show(); b.show();
b=a++;
a.show(); b.show();
}
*/
/*
//358p NO.7-14
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0){
this->kick=kick; this->punch=punch;
}
void show();
Power& operator << (int n);
};
void Power::show(){
cout<< "kick= " << kick << ',' << "punch= " << punch<<endl;
}
Power& Power:: operator << (int n) {
kick+= n;
punch=+n;
return *this;
}
int main() {
Power a(1,2);
a << 3<< 5<<6;
a.show();
}
*/