int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1:putchar (c+2); case 2:putchar (int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1: case 2:putchar ("%d",a[i++]);braek;case 3 :putchar ("%d",a[--i]);}}答案是55,

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/13 03:30:23

int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1:putchar (c+2); case 2:putchar (int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1: case 2:putchar ("%d",a[i++]);braek;case 3 :putchar ("%d",a[--i]);}}答案是55,
int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1:putchar (c+2); case 2:putchar (
int a[]={1,2,3,4,5,6,7},i=5,j;
for (j=3;j>1;j--)
switch (j)
{ case 1:
case 2:putchar ("%d",a[i++]);braek;
case 3 :putchar ("%d",a[--i]);
}
}
答案是55,为什么?

int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1:putchar (c+2); case 2:putchar (int a[]={1,2,3,4,5,6,7},i=5,j; for (j=3;j>1;j--) switch (j) { case 1: case 2:putchar ("%d",a[i++]);braek;case 3 :putchar ("%d",a[--i]);}}答案是55,
j=3 符合条件 case 3 输出 a[- -i] 即a[4] 输出5
然后j - - j 变为2 2>1 符合条件
j=2 case 2 输出a[i++] 因为刚刚 i 执行了- - i i的值已经为4
此时i的值仍为4 不执行i ++ 及输出a[4] 输出5
case 2:putchar ("%d",a[i++]);braek;
case 3 :putchar ("%d",a[--i]);braek; "%d\n"这样才有换行的效果
因为你没有加\n 换行 所有两个5 连在一起输出啦