mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-05-12 02:48:08 +08:00
support bazel complie this project and format code.
This commit is contained in:
23
practical_exercises/10_day_practice/day9/exception/4.cpp
Normal file
23
practical_exercises/10_day_practice/day9/exception/4.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
void temperature(int t) {
|
||||
|
||||
if (t == 100)
|
||||
throw "沸点!";
|
||||
else if (t == 0)
|
||||
throw "冰点!";
|
||||
else {
|
||||
cout << "temperatore=" << t << endl;
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
try {
|
||||
temperature(0); // L1
|
||||
temperature(10); // L2
|
||||
temperature(100); // L3
|
||||
} catch (char const *s) {
|
||||
cout << s << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user