首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #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[i]%2)
有以下程序 #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[i]%2)
admin
2019-07-14
15
问题
有以下程序
#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://kaotiyun.com/show/L8Rp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序#includeint*f(int*s,int*t){if(*s<*t)*s=*t;returns;}main(){inti=3,j=5,*p=&i,*q=&j,*r;r=f(p,q);pri
有以下程序#includestructord{intx,y;}dt[2]={1,2,3,4};main(){structord*p=dt;printf("%d,",++(p->x));printf("%d\n",++(p-
有以下程序#includemain(){FILE*fp;inta[10]={1,2,3},i,n;fp=fopen("d1.dat","w");for(i=0;i
有以下程序#includemain(){unsignedchara=8,c;c=a>>3;printf("%d\n",c);}程序运行后的输出结果是()。
在数据库设计中,将E—R图转换成关系数据模型的过程属于()。
有三个关系R、S和T如下:则关系T是由关系R和S通过某种操作得到,该操作为( )。
随机试题
MaryArming(1799—1847)wasaBritishfossilhunterwhobeganfinding【21】asachild,andsoonsupportedherselfandhervery【22】
关于腰椎前后位成像技术标准的叙述,不正确的是
某外商投资企业银行存款(美元)账户上期期末余额为50000美元,上期末市场汇率为1美元=6.30元人民币,该企业外币交易采用当日市场汇率折算,该企业本月10日将其中10000美元在银行兑换为人民币,银行当日美元买入价为1美元=6.25元人民币,当日市场汇率
中国电信行业经历了三次重大改革后,从完全垄断走向寡头竞争格局。但是。行业垄断状况依然严重。在移动市场上,中国移动“一家独大”,在宽带市场上,中国电信和中国联通南北垄断。中国电信行业仍然是政府管制下的强垄断市场,其强垄断状况将电信资费维持在较高的水平,不仅降
下列对子网系统的防火墙的描述错误的是
ComputertechnologyhasmadecheckingdictionarieswritteninChineseamuchmore(i)______task.SincetheChineselanguagesdid
ProductionoftheAmbassador,thefirstcartobemadeinIndia,hasbeenhaltedbecauseoffallingdemand.ModelledontheMorr
Yourweightaffectshowlongyoulive—butit’sextremelycomplicatedA)Weoftenthinkaboutweightlossintheshortterm,h
A、Soughtafterbytoomanypeople.B、Toodifficultforyoungpeople.C、Forambitiouspeopleonly.D、Foryoungpeopleonly.A
A、Becausehedislikedhisradio.B、Becausehedidn’treturntheradiotothewoman.C、Becausehelefthisradiotooloud.D、Beca
最新回复
(
0
)