[C++]명품 C++ programming 실습문제 6장 3번
명품 C++ 프로그래밍실습문제/연습문제 /C++
//3-1
#include <iostream>
#include <string>
using namespace std;
int big(int a ,int b);
int big(int a, int b, int max);
int main(int argc, const char * argv[]) {
int x =big(3,5);
int y =big(300,60);
int z =big(30,60,50);
cout << x << ' ' << y << ' ' << z << endl;
return 0;
}
int big(int a ,int b){
int max = 100;
if(a>b){
if(max>a){
return a;
}
else
return max;
}
else{
if(max>b){
return b;
}
else
return max;
}
}
int big(int a ,int b,int max){//구현부에서 재구현을 할필요는 없다
if(a>b){
if(max>a){
return a;
}
else
return max;
}
else{
if(max>b){
return b;
}
else
return max;
}
}
//3-2
#include <iostream>
#include <string>
using namespace std;
int big(int a ,int b,int max=100);
int main(int argc, const char * argv[]) {
int x =big(3,5);
int y =big(300,60);
int z =big(30,60,50);
cout << x << ' ' << y << ' ' << z << endl;
return 0;
}
int big(int a ,int b,int max){//구현부에서 재구현을 할필요는 없다
if(a>b){
if(max>a){
return a;
}
else
return max;
}
else{
if(max>b){
return b;
}
else
return max;
}
}
'C++' 카테고리의 다른 글
[C++] 명품 C++ 프로그래밍 실습문제 6장 6번 (0) | 2023.01.10 |
---|---|
[C++] 명품 C++ 프로그래밍 실습문제 6장 4번 (0) | 2023.01.10 |
[C++] 명품 C++ 프로그래밍 실습문제 6장 2번 (0) | 2023.01.07 |
[C++] 명품 C++ 프로그래밍 실습문제 6장 오픈챌린지/openchallenge (0) | 2023.01.06 |
명품 C++ 실습문제 5장 12,12-1번 (2) | 2023.01.05 |