单选题
有以下程序
#include
void main()
{int a[]={2,3,5,4},i;
for(i=0;i<4;i++)
switch(i%2)
{case 0:switch(a[i]%2)
{case 0:a[i]++;break;
case 1:a[i]--;
}break;
case 1:a[i]=0;
}
for(i=0;i<4;i++)
printf("%d",a[i]);
printf("\n");}
程序运行后的输出结果是
【正确答案】
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。