单项选择题

下列函数的运行结果是( )。
#include<iostream.h>
int f(int a,int b)
int c;
if(a>b)c=1;
else if(a==b)c=0;
else c=-1;
return(c);
void main()
int i=2,j=3;
iht p=f(i,j);
cout<<p;

A.-1
B.1
C.2
D.编译出错,无法运行
<上一题 目录 下一题>
热门 试题

单项选择题
有以下程序: Class Date public: Date(int y,int m,mt d); year=y; month=m; day=d; Date(int y=2000) year=y; month=10; day=1; Date(Date &d) year=d.year; month=d.month; day=d.day; Void print() cout<<year<< . <<month<< . <<day<<endl; private: int year,month,day; ; Date fun(Date d) Date temp; temp=d; return temp; mt main() Date date1(2000,1,1),date2(0,0,0); Date date3(datel); date2=fun(date3); return 0; 程序执行时,Date类的拷贝构造函数被调用的次数是( )。
A.2
B.3
C.4
D.5
单项选择题
如有下程序: #include<iostream> using namespace std; long fun(int n) if(n>2) return(fun(n-1)+fun(n-2)); else return 2; int main() cout<<fun(3)<<endl; return 0; 则该程序的输出结果应该是( )。
A.2
B.3
C.4.
D.5
相关试题
  • 表达式c3=c1.operator+(c2)或c3=...
  • 程序中有如下语句: for(int i=0;i<...
  • 下列程序在构造函数和析构函数中申请和释放...
  • 用以下语句调用库函数malloc,使字符指针st...
  • 有如下定义: Class MA int value; p...