首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize;
有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize;
admin
2010-03-29
36
问题
有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize; int *array; cout<<"Please input the size of the array:"; cin>>arraySiZe; array=new int[arraysize]; if(array==NULL) { cout<<"allocate Error\n"; exit(1); } for(int i=0;i<arraysize;i++) array
=i*i; int j; cout<<"which element you want to check:"; cin>>j; cout<<array[j]<<end1; return 0; } 执行程序输入:10<空格>5,则输出结果为( )。
选项
A、allocate Error
B、1
C、0
D、25
答案
8
解析
程序中利用new()申请动态分配数组。利用for循环给数组array赋值。最后输出想要检查元素的值。程序输10,即数组array元素个数为10。程序输入5,即检查元素array[5]的值。由for循环的赋值运算可知array[5]的值为25,所以程序最后输出25。
转载请注明原文地址:https://kaotiyun.com/show/fFjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序#includemain(){inta=0,b=0,c=0,d=0;(++a||++b)?++c:++d;printf("%d,%d,%d,%d\n",a,b,c,d);}程序的运行结果是()。
以下叙述中正确的是
设有定义:doublex=2.12;,以下不能完整输出变量x值的语句是()。
以下函数的功能是:通过键盘输入数据,为数组中的所有元素赋值。#include#defineN10voidfun(intx[N]){inti=0;while(i<N)scanf("%d",___);}在程序中下划线处应填入
在C语言中,函数返回值的类型最终取决于
下列各组的排序方法中,最坏情况下比较次数相同的是
如果需要打开一个已经存在的非空文件“FILE”并进行修改,正确的语句是()。
算术运算符和圆括号有不同的运算优先级,对于表达式:a+b+c*(d+e),关于执行顺序,以下说法正确的是()。
下列关于逻辑运算符两侧运算对象的叙述中正确的是()。
下列关于逻辑运算符两侧运算对象的叙述中正确的是()。
随机试题
邓小平指出:“在剥削阶级作。为阶级消灭以后,阶级斗争已经不是主要矛盾。由于国内的因素和国际的影响,阶级斗争还将在—定范围内长期存在,在某种条件下还有可能激化。”这一论断说明()
A、5°B、20°C、30°D、45°E、90°前牙3/4冠切沟顶角的角度
国有资产产权登记具有确认()的效力。
行政行为在空间上的表现形式和在时间上的跨度,包括行政行为方式、步骤、次序、时限等不可分割的内容的是()
已知某运动会田径综合赛以选手三项运动的综合积分高低决定排名。具体积分规则如下表1所示,而某队四位队员的模拟成绩如表2。据此,该代表队应选派参赛的队员是:
Intheolddays,sendingathank-younotetoarelativewaseasy.Youwroteit,【1】,astampontheenvelopeanddroppedit【2】am
ReadthetextbelowabouttheevolutionofAmericanbusiness.Inmostofthelines41—52thereisoneextraword.Itiseither
ThePurposesofLiteraryAnalysisI.IntroductionLiteraryanalysisisinitselfauniversalnecessity.—reason1:enablesrea
TheUseofChildren’sLiteratureinEnglishTeachingI.Acase:the【T1】______inchildren’sliteraturehelpingthemlearnEnglish
Hesaiditwouldnotbeallthatdifficulttoreachapeacefulconclusiontothe
最新回复
(
0
)