(难)有关scanf和gets的4道题.请高手赐教.并能说说他们的用法吗.我实在搞不懂
46.若有定义和语句:int x ;float y ;char z[10] ,c ;
scanf (”%3d%f%3s%c” ,&x,&y,z,&c);
执行时输入12345└┘└┘└┘book└┘$↙
则x的值是[51],y的值是[52],z的值是[53],c的值是[54]
[51]A.12345 B. 45 C. 123 D. 无答案
[52]A.123.0 B. 45 C. 45.0 D.无答案
[53]A.└┘└┘└┘ B. book C. boo D.无答案
[54]A.$ B.└┘ C. k D.无答案
47.若执行下面程序时输入pen↙
book↙
#include<stdio.h>
#include<string.h>
main()
{char a1[5],a2[5];scanf(”%s”,a1);gets(a2);
puts(a1);puts(a2);printf(”%d\n”,strlen(a2));}
则结果是
[55] A. pen B. pen book C. pen D.无答案
book
4 0 0
50.若执行下面程序时输入pen↙
book↙
#include<stdio.h>
#include<string.h> main()
{ char a1[5],a2[5];gets(a1);gets(a2);
puts(a1);puts(a2);printf(”%d\n”,strlen(a2));}
则结果是
[58]A. pen B. pen book C. pen D. 无答案
book
0 0 4
51.若执行下面程序时输入aa└┘bb↙
cc└┘dd↙
#include<stdio.h>
main()
{ char a1[5],a2[5],a3[5],a4[5];scanf(”%s%s”,a1,a2);gets(a3);gets(a4);
puts(a1);puts(a2);puts(a3);puts(a4);}
则结果是
[59]A. aa B. aa C. aa D. aa└┘bb
bb bb bb cc
cc└┘dd cc dd
dd cc└┘dd