6,8,10,12번 다시 해보기
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
/*
//270P NO.02
void half(double &n){
n=n/2;
}
int main() {
double n=20;
half(n);
cout<<n;
}
*/
/*
//270P NO.04
bool bigger(int a, int b, int& big){
if(a==b) return true;
if(a>b) big=a;
else big=b;
return false;
};
int main() {
int x, y, big, b;
cin>>x>>y;
b=(x,y,big);
if(b) cout<<"same"<<endl;
else cout << "큰 수는"<< big << endl;
}
*/
/*
//270P NO.05
class Circle{
int radius;
public:
Circle(int r) {radius=r;}
int getRadius() {return radius;}
void setRadius(int r) { radius=r;}
void show(){cout << "반지름이 " << radius<< "인 원"<<endl;}
};
void increaseBy(Circle& a, Circle& b) {
int r = a.getRadius() + b.getRadius();
a.setRadius(r);
}
int main(){
Circle x(10), y(5);
increaseBy(x,y);
x.show();
}
*/
/*
//271P NO.06
//문자열과 문자 비교하는거 방법
char& Find(char a[], char c, bool& success){
if() return& true;
else return& false;
};
int main(){
char s[] = "Mike";
bool b= false;
char& loc = Find(s, 'M', b);
if(b==false){
cout << "M을 발견할 수 없다"<< endl;
return 0;
}
loc='m';
cout <<s<<endl;
}
*/
/*
//272P NO.07
class MyInStack{
int p[10];
int tos;
public :
MyInStack();
bool push(int n);
bool pop(int &n);
};
MyInStack::MyInStack(){
tos=0;
}
bool MyInStack::push(int n){
if(tos==10) return false;
p[tos] =n;
tos++;
return true;
}
bool MyInStack::pop(int &n){
if(tos == 0) return false;
tos--;
n = p[tos];
return true;
}
int main() {
MyInStack a;
for(int i=0; i<11; i++){
if(a.push(i)) cout<< i<< ' ';
else cout<< endl << i+1 << " 번째 stack full" << endl;
}
int n;
for(int i=0; i<11; i++){
if(a.pop(n)) cout<<n<<' ';
else cout<< endl<< i+1<< " 번째 stack empty";
}
cout<<endl;
}
*/
/*
//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;
}
MyInStack::MyInStack(int Size){
tos=Size;
}
MyInStack::MyInStack(const MyInStack& s){
}
MyInStack::~MyInStack(){
}
bool MyInStack::push(int n){
if(tos==10) return false;
p[tos] =n;
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);
int n;
a.pop(n);
cout<< "스텍 a에서 팝한 값 " << n<< endl;
b.pop(n);
cout<< "스텍 b에서 팝한 값" << n << endl;
}
*/
/*
//273P NO.09
class Accumulator{
int value;
public:
Accumulator(int value);
Accumulator& add(int n);
int get(){return value;}
};
Accumulator::Accumulator(int value){
this->value=value;
}
Accumulator& Accumulator:: add(int n){
value+=n;
}
int main(){
Accumulator acc(10);
acc.add(5).add(6).add(7);
cout<< acc.get();
}
*/
/*
//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;}
};
char append(char& a[], char& b){
text= a[]+b;
}
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();
int getSize() {return Size;}
void read();
bool isOver60(int index);
};
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<< "명";
}
*/