/*
https://www.hackerrank.com/challenges/30-exceptions-string-to-integer/problem
Note that you can't use "if" in this problem
*/
void valid(string S){
int result;
try{
result = stoi(S);
}
catch (exception e) {
cout << "Bad String";
return;
}
cout << result;
}
int main(){
string S;
cin >> S;
valid(S);
return 0;
}
댓글 없음:
댓글 쓰기