double b = - 5.8976;
cout <&"> double b = - 5.8976;
cout <&">

#include < iostream >
using namespace std;
template < class T >
T F(T x)
{
return x > 5;
}
void main( )
{
int a = 15;
cout << F(a) << " \n";
double b = - 5.8976;
cout <&

程序分析题:阅读程序后,填写程序的正确运行结果。


#include < iostream >
using namespace std;
template < class T >
T F(T x)
{
return x > 5;
}
void main( )
{
int a = 15;
cout << F(a) << " \n";
double b = - 5.8976;
cout << F(b) << " \n";
cout << F(5) <<" \n";
}


【正确答案】:

1
0
0


【题目解析】:

函数F的作用是判断输入的数是否大于5,如果不大于5,则返回0,如果大于5,则返回1。

F(a) ,F(15) , 15>5,返回真,即1
F(b) ,F(-5.8976) ,返回假,即0
F(5) ,5>5,返回假,即0


Top