[C++]명품 C++ 프로그래밍 실습문제 13장 3번
[C++]명품 C++ programming 실습문제 13장 3번
명품 C++ 프로그래밍실습문제/연습문제 /C++
#include <iostream>
#include <fstream>
using namespace std;
int get();
int main(){
int num1,num2;
while (1)
{
try{
cout << "0~9 사이의 정수입력 >>";
num1= get();
cout << "0~9 사이의 정수입력 >>";
num2= get();
cout << num1*num2<< endl;
}
catch(const char *s){
cout <<s<< endl;
}
}
return 0;
}
int get() {
const char *str = "ERROR: 예외 발생 계산할수 없음";
int temp = 0;
cin >> temp;
if (temp < 0 || 9 < temp)
throw str;
return temp;
}
'C++' 카테고리의 다른 글
[C++]명품 C++ 프로그래밍 실습문제 13장 6번 (0) | 2023.01.29 |
---|---|
[C++]명품 C++ 프로그래밍 실습문제 13장 4번 (0) | 2023.01.29 |
[C++]명품 C++ 프로그래밍 실습문제 13장 2번 (0) | 2023.01.28 |
[C++]명품 C++ 프로그래밍 실습문제 12장 14번 (0) | 2023.01.27 |
[C++]명품 C++ 프로그래밍 실습문제 12장 13번 (0) | 2023.01.27 |