有以下程序: #include<stdio.h> main() {int a1,a2;char c1,c2; scanf("%d%c%d%c",&a1,&c1,&a2,&c2); printf("%(1,%c,%d,%c",a1,c1,a2,c2); }

admin2021-02-25  31

问题 有以下程序:
#include<stdio.h>
main()
{int a1,a2;char c1,c2;
scanf("%d%c%d%c",&a1,&c1,&a2,&c2);
printf("%(1,%c,%d,%c",a1,c1,a2,c2);
}
若想通过键盘输入,使得a1的值为12,a2的值为34,c1的值为字符a,c2的值为字符b,程序运行后的输出结果是:12,a,34,b。则正确的输人格式是(以下代表空格,<CR>代表回车)(  )。

选项 A、12b<CR>
B、12b<CR>
C、12,a,34,h<CR>
D、12a34h<CR>

答案D

解析 存输入多个数据时,若格式控制串中无非格式字符,则认为所有输入的字符均为有效字符。所以应按选项D的顺序输入数据。
转载请注明原文地址:https://kaotiyun.com/show/9otp777K
0

随机试题
最新回复(0)