首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include<stdio.h> void main() {int a[]={2,3,5,4},i; for(i=0;i<4;i++) switch(i%2) {case 0:swi
有以下程序 #include<stdio.h> void main() {int a[]={2,3,5,4},i; for(i=0;i<4;i++) switch(i%2) {case 0:swi
admin
2017-04-26
22
问题
有以下程序
#include<stdio.h>
void main()
{int a[]={2,3,5,4},i;
for(i=0;i<4;i++)
switch(i%2)
{case 0:switch(a
%2)
{case 0:a
++;break;
case 1:a
--;
}break;
case 1:a
=0;
}
for(i=0;i<4;i++)
printf("%d",a
);
printf("\n");}
程序运行后的输出结果是
选项
A、2 0 5 0
B、3 3 4 4
C、3 0 4 0
D、0 3 0 4
答案
C
解析
在主函数的for循环语句中,当循环变量i的值等于0,2时,执行switch中的case 0语句,分别对数组元素a[0]和a[2]加1和减1,所以a[0]的值等于3,a[2]等于4。当循环变量i的值等于1,3时,执行switch中的case 1语句,把数组元素a[1]和a[3]的值赋为0。所以输出数组a的元素,其结果为3040。
转载请注明原文地址:https://jikaoti.com/ti/FCi0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。例如,若一维数组中的数据是:2223445666677899101010删除后,数
有以下程序#includemain(){ints[12]={1,2,3,4,4,3,2,1,1,1,2,3},c[5]={0},i;for(i=0;i
已知大写字母A的ASCII码是65,小写字母a的ASCII码是97。以下不能将变量c中的大写字母转换为对应小写字母的语句是
下面程序的功能是输出数组s中最大元素的下标,请填空。main(){intk,p,s[]={1,-9,7,2,-10,3};for(p=0,k=p;ps[k])【】printf("%d\n",k);}
按"先进后出"原则组织数据的数据结构是【】。
以下scanf函数调用语句中对结构体变量成员的引用不正确的是structpupil{charname[20];intageintsex;}pup[5],*p;p=pup;
下列对于软件测试的描述中正确的是
当用户要求输入的字符串中含有空格时,应使用的输入函数是
软件生命周期分为软件定义期、软件开发期和软件维护期,详细设计属于______中的一个阶段。
数据字典是各类数据描述的集合,它通常包括5个部分,即数据项、数据结构、数据流、()和处理过程。
随机试题
(2005)数字系统中,有三种最基本的逻辑关系,这些逻辑关系的常用表达式为()。
室内涂膜防水施工,玻纤布的接槎应顺流水方向搭接,搭接宽度应不小于()mm。
某基坑降水可能引起邻近建(构)筑物、管线的不均匀沉降或开裂,此基坑宜选用的降水方案是()。
下列关于小型电热设备防火措施检查的叙述中,错误的是()。
甲公司2011年至2013年与无形资产业务有关的资料如下:(1)2011年1月1日,以分期付款方式从乙公司购买一项无形资产,购买合同注明该项无形资产总价款为1400万元,于2011年1月1日支付200万元,其余款项从2011年12月31日至201
以现金结算的股份支付,企业应在可行权日之后的每个资产负债表日重新计量相关负债的公允价值,并将其与账面价值的差额列示在利润表中的项目为()。
精装书书壳超出书心切口的部分称为()。
关于SAS的施测步骤,下列说法中正确的是()。
第三党
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下面图符名标识的图符不属于数据流图合法图符的是()。
最新回复
(
0
)