// 1번문제
/*
#include <iostream.h>
int main()
{
	int A,B,E;
	int *C=&A;

	A=5;
	B=7;

	cout<<"A의 주소를 출력 :"<<C<<"\n";

	cout<<"A값을 출력 :"<<*C<<"\n";

	int &rA=B;

	cout<<"참조자A를 출력 :"<<rA<<"\n";

	E=*C+rA;

	cout<<E;

	return 0;

}
*/

// 2번문제
/*
#include <iostream.h>
int main()
{
	int A=6;
	int *varOne = &A;
	cout<<"A ="<<*varOne<<"\n";
	*varOne = 7;
	cout<<"varOne ="<<*varOne<<"\n";
	int varTwo=10;
	varOne = &varTwo;
	cout<<"varone ="<<*varOne<<"\n";
	return 0;
}
*/
//5번문제


#include <iostream.h>
void fn(int *A,int *B);
int main()
{
	int A,B;
	cout<<"first no. ?";
	cin>>A;
	cout<<"second no. ?";
	cin>>B;
	fn(&A, &B);
//	cout<<"A+B ="<<*K<<"\n";
//	cout<<"A-B ="<<*L<<"\n";
	return 0;
}
void fn(int *AA,int *BB)
{
	int M;
	M=*AA+*BB;
	int N=*AA-*BB;
	int *K=new int;
	*K= &M;
	int *L=new int;
	*L= &N;
}

//fn함수에 있는 포인터K,L값을 메인에서 읽을려고 하는데 못하겠군요..ㅠㅠ 어떻게 해야죠?
//이렇게 프로그램 복잡하게 만들 필요는 없겠지만 그냥 포인터 써서 함수에 있는 두 값 읽어오는거 해 보고 싶어서..ㅋㅋ
//5번문제가 new를 쓰고 delate안쓰는 메모리 누출문제인데...이렇게 하면 되긴 되는건지..ㅠㅠ

