#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
/*
//272P NO.08
class MyInStack{
int *p;
int Size;
int tos;
public:
MyInStack();
MyInStack(int Size);
MyInStack(const MyInStack& s);
~MyInStack();
bool push(int n);
bool pop(int &n);
};
MyInStack::MyInStack(){
tos=0;
cout << "Init St1";
}
MyInStack::MyInStack(int Size){
this->Size=Size;
tos = 0;
p = new int[Size];
cout << "Init St2";
}
MyInStack::MyInStack(const MyInStack& s){
this->p = s.p;
this->Size = s.Size;
this->tos = s.tos;
}
MyInStack::~MyInStack(){
}
bool MyInStack::push(int n){
if(tos==10) return false;
p[tos] =n;
cout << "inand : " << n << endl;
tos++;
return true;
}
bool MyInStack::pop(int &n){
if(tos == 0) return false;
tos--;
n = p[tos];
return true;
}
int main() {
MyInStack a(10);
a.push(10);
a.push(20);
MyInStack b=a;
b.push(30);
cout<<1;
int n;
a.pop(n);
cout<< "스텍 a에서 팝한 값 " << n<< endl;
b.pop(n);
cout<< "스텍 b에서 팝한 값" << n << endl;
}
*/
/*
//274P NO.10_ append 함수 다시 작성
class Buffer{
string text;
public:
Buffer(string text){this->text=text;}
void add(string next) {text+=next;}
void print(){cout<<text<<endl;}
};
Buffer& append(Buffer& a,char *b){
a.add(b);
return a;
}
int main() {
Buffer buf("Hello");
Buffer& temp= append(buf, "Guys");
temp.print();
buf.print();
}
*/
/*
//275P NO.12
class Dept{
int Size;
int*scores;
public:
Dept(int Size){
this->Size=Size;
scores= new int[Size];
}
Dept(const Dept& dept);
~Dept(){delete[] scores;}
int getSize() {return Size;}
void read();
bool isOver60(int index);
};
void Dept::read(){
int n, i;
cout<<"10개의 점수 입력>> ";
for( i=0; i<Size; i++){
cin>>n;
scores[i]=n;
}
}
Dept::Dept(const Dept& dept){
this->Size=dept.Size;
this->scores=new int [this->Size];
for(int i=0; i<dept.Size; i++){
this->scores[i]=dept.scores[i];
}
}
bool Dept::isOver60(int index){
if(scores[index]>60) return true;
else return false;
}
int countPass(Dept dept){
int Count=0;
for(int i=0; i,dept.getSize(); i++){
if(dept.isOver60(i)) Count++;
}
return Count;
}
int main() {
Dept com(10);
com.read();
int n = countPass(com);
cout<< "60점 이상은 "<< n<< "명";
}
*/
/*
//280P 예제6-1
int big(int a, int b){
if(a>b) return a;
else return b;
}
int big(int a[], int Size){
int res =a[0];
for(int i=1; i<Size; i++)
if(res<a[i]) res=a[i];
return res;
}
int main(){
int array[5]={1, 9, -2, 8, 6};
cout<< big(2, 3)<<endl;
cout<<big(array, 5)<< endl;
}
*/
/*
//281P 예제6-2
int sum(int a, int b){
int s=0;
for(int i=a; i<=b; i++)
s+=i;
return s;
}
int sum(int a){
int s=0;
for(int i=0; i<=a; i++)
s+=i;
return s;
}
int main(){
cout<<sum(3, 5) << endl;
cout<<sum(3)<<endl;
cout<<sum(100)<<endl;
}
*/
/*
//286P 예제6-3
void star(int a=5);
void msg(int id, string text="");
void star(int a){
for(int i=0; i<a; i++) cout<< '*';
cout<<endl;
}
void msg(int id, string text) {
cout<< id<< ' '<< text<< endl;
}
int main(){
star();
star(10);
msg(10);
msg(10,"Hello");
}
*/
/*
//287P 예제6-4
void f(char c=' ', int line=1);
void f(char c, int line){
for(int i=0; i<line; i++){
for(int j=0; j<10; j++)
cout<<c;
cout<<endl;
}
}
int main(){
f();
f('%');
f('@', 5);
}
*/
/*
//289P 예제6-5
void fillLine(int n=25, char c='*'){
for(int i=0; i<n; i++)
cout << c;
cout<<endl;
}
int main(){
fillLine();
fillLine(10,'%');
}
*/
/*
//290P 예제6-6
class MyVector{
int *p;
int Size;
public:
MyVector(int n=100){
p= new int [n];
Size=n;
}
~MyVector() {delete [] p;}
};
int main(){
MyVector *v1,*v2;
v1 = new MyVector();
v2 = new MyVector(1024);
delete v1;
delete v2;
}
*/
/*
//293P 예제6-7
float square(float a){
return a*a;
}
double square(double a){
return a*a;
}
int main(){
cout<<square(3.0);
cout<<square(3);
}
*/
/*
//294P 예제6-8
int add(int a, int b){
return a+b;
}
int add(int a, int &b){
b=b+a;
return b;
}
int main(){
int s=10, t=20;
cout<< add(s,t);
}
*/
/*
//295P 예제6-9
void msg(int id){
cout<< id<< endl;
}
void msg(int id, string s=""){
cout<<id << ":"<<s<<endl;
}
int main(){
msg(5, "Good Morning");
msg(6);
}
*/
/*
//303P 예제6-10
class Math{
public:
static int abs(int a) {return a>-0?a:-a;}
static int max(int a, int b) {return (a>b)?a:b;}
static int min(int a, int b) {return (a>b)?b:a;}
};
int main(){
cout<< Math::abs(-5)<<endl;
cout<< Math::max(10, 8) << endl;
cout << Math::min(-3, -8)<< endl;
}
*/
/*
//304P 예제6-11
class Circle{
private:
static int numOfCircles;
int radius;
public:
Circle(int r=1);
~Circle() {numOfCircles--;}
double getArea() {return 3.14*radius*radius;}
static int getNumOfCircles(){return numOfCircles;}
};
Circle::Circle(int r){
radius=r;
numOfCircles++;
}
int Circle::numOfCircles=0;
int main() {
Circle *p = new Circle[10];
cout<<"생존하고 있는 원의 개수 = " << Circle::getNumOfCircles()<<endl;
delete []p;
cout<<"생존하고 있는 원의 개수 = " << Circle::getNumOfCircles()<<endl;
Circle a;
cout<<"생존하고 있는 원의 개수 = " << Circle::getNumOfCircles()<<endl;
Circle b;
cout<<"생존하고 있는 원의 개수 = " << Circle::getNumOfCircles()<<endl;
}
*/
/*
//313p NO.01
int main(){
int a[]={1, 2, 3, 4, 5};
int b[]={6, 7, 8, 9, 10};
int c = add(a,5);
int d = addd(a, 5, b);
cout<< c<< endl;
cout<<d<< endl;
}*/
/*
//313p NO.02
class Person{
int id;
double weight;
string name;
public:
Person();
Person(int id, string text="");
Person(int id, string text="", double weight);
void show(){cout<<id<<' '<<weight<<' ' <<name<< endl;}
};
Person::Person(){
}
void grace(int 1, double 20.5, string "grace");
void ashley(double 20.5);
int main() {
Person grace, ashley(2, "Ashley"), helen(3, "Helen", 32.5);
grace.show();
ashley.show();
helen.shoe();
}
*/