首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include <iostream> using namespace std; class CFactorial { private: int value; int fact
有以下程序: #include <iostream> using namespace std; class CFactorial { private: int value; int fact
admin
2010-03-29
35
问题
有以下程序:
#include <iostream>
using namespace std;
class CFactorial
{
private:
int value;
int fact;
public:
CFactorial ( int val );
void CalculateFactorial();
void Display();
};
CFactorial :: CFactorial( int val )
{
value = val;
fact = 1;
}
void CFactorial :: CalculateFactorial()
{
int i = value;
while ( i > 1 )
fact *= i--;
}
void CFactorial :: Display()
{
cout<<value<<"!="<<fact<<end1;
}
int main()
{
CFactorial A( 5 );
A.CalculateFactorial();
A.Display();
return 0;
}
程序中,类CPactorial的功能是【 】,该程序运行的结果是【 】。
选项
答案
求自然数的阶乘 120
解析
类CFactorial中的成员函数CalculateFactorial()实现的功能是:求自然数value的阶乘结果。
转载请注明原文地址:https://kaotiyun.com/show/YJjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有下列程序:main(){inti,s=0,t[]={1,2,3,4,5,6,7,8,9};for(i=0;i<9;i+=2)s+=*(t+i);printf(”%d\n”,s);}程序执行
关于C语言中数的表示,以下叙述正确的是
若有以下程序#includemain(){inta=1,b=2,c=3,d=4,r=0;if(a!=1);elser=1;if(b==2)r+=2;if(c!=3);r+=3;if(d==4)r+=4
数据库设计的根本目标是要解决
在C语言程序中,以下说法正确的是()。
若有如下说明,且int类型占两个字节,则正确的叙述为()。structst{inta;intb[2];}a;
下列序列中不满足堆条件的是
以下不合法的字符常量是
使用VC++2010打开考生文件夹下modi1中的解决方案。此解决方案的项目中包含一个源程序文件modi1.c。在此程序中,函数fun的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在t中。高仍在高位,低位仍在低位。例如,当s中的数为876
在软件开发中,需求分析阶段可以使用的工具是()。
随机试题
以孔子为代表的倡导的“内圣外王”、追求中庸之道的思想是()
Shewasapoorwomanwithfew______.
Ⅲ类地表水环境pH标准限值是()。
基本农田保护实行全面规划、()、用养结合、严格保护的方针。
求助者的主要心理问题包括()。这段咨询最有可能是发生在()。
Soft-drinksaleshavebeendecliningforninestraightyears.Thisismuchmorethanatrend—it’safundamentalshiftinconsum
输出设备的作用是将计算机内部______表示形式的信息转换成人们所需要的或其他设备能接受和识别的信息形式。
以下过程的功能是从数组中寻找最大值:PrivateSubFindMax(a()AsInteger,ByRefMaxAsInteger) DimsAsInteger,fAsInteger DimiAsInteger
按数据的组织形式,数据库的数据模型可分为三种模型,它们是( )。
Amorphemeisthesmallestmeaningfulunitinthegrammarofalanguage.Theworddogsconsistsofmorphemesandonesyllable,a
最新回复
(
0
)