单选题:当变量x的输入值是9时,下面程序的运行结果是:
当变量$$x$$的输入值是9时,下面程序的运行结果是:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x;
cin>>x;
try
{
cout<<"begin"<<endl;
if(x>100)
{
cout<<"1"<<endl;
throw string("too big.");
}
else
{
cout<<"x="<<x<<endl;
}
cout<<"2"<<endl;
}
catch(string e)
{
cout<<"3:"<<e<<endl;
}
cout<<"end"<<endl;
return 0;
}
A.begin
1
2
end
B.begin
1
3: too big.
2
end
C.begin
x=9
2
end
D.begin
1
3: too big.
end
answer:C
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x;
cin>>x;
try
{
cout<<"begin"<<endl;
if(x>100)
{
cout<<"1"<<endl;
throw string("too big.");
}
else
{
cout<<"x="<<x<<endl;
}
cout<<"2"<<endl;
}
catch(string e)
{
cout<<"3:"<<e<<endl;
}
cout<<"end"<<endl;
return 0;
}
A.begin
1
2
end
B.begin
1
3: too big.
2
end
C.begin
x=9
2
end
D.begin
1
3: too big.
end
answer:C