老实说,我收到错误感到震惊。我是一名初级 CS 专业的学生,我无法让这个简单的程序正常工作。Clion 说这两行无法访问,但我的测试用例似乎有效。
代码:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = "";
while(s != "|") {
int val1 = 0;
int val2 = 0;
cin >> val1;
cin >> val2;
if(val1 == val2) {
cout << "the numbers are equal.\n";
} else {
cout << "the smaller value is: " << min(val1, val2) << '\n'; // Says these two
cout << "the larger value is: " << max(val1, val2) << '\n'; // lines are unreachable
}
cin >> s;
}
return 0;
}
测试用例:
3 3
the numbers are equal.
f
4 5
the smaller value is: 4
the larger value is: 5
|
Process finished with exit code 0
如果此代码如此无法访问,那么我的程序如何到达它?