U E D R , A S I H C RSS

중위수구하기/남도연

-----<hahaha.h>------
~cpp 
class Mid{
private:
	int x,y,z,center;
public:
	Mid();
	~Mid();
	void input();
	void comparison();
	void disp();
};
-----<hahaha.cpp>----
~cpp 
#include <iostream.h>
#include "hahaha.h"
Mid :: Mid (){
	x=0;
	y=0;
	z=0;
}
Mid :: ~Mid(){
}
void Mid :: input(){
	cout<<"비교할 세 수를 입력하세요"<<endl;
	cin>>x>>y>>z;
}
void Mid :: comparison (){
	if ((x>=y && x<=z) || (x<=y && x>=z)) {
		center = x;
	}
	else if ((y>=x && y<=z) || (y<=x && y>=z)) {
		center = y;
	}
	else  {
		center = z;
	}
}
void Mid :: disp(){
	if (x==-999||y==-999||z==-999){
		cout<<"프로그램 종료"<<endl;
	}
	else {
	cout<<"A="<<x<<" B="<<y<<" C="<<z<<endl;
	cout<<"중위수는 "<<center<<"입니다."<<endl;
	}
}
-----<hahaha2.cpp>-----
~cpp 
#include "hahaha.h"

void main(){
	Mid center;
	center.input();
	center.comparison();
	center.disp();
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:09
Processing time 0.0168 sec