(46)阅读下列程序,则执行后的输出结果为
#include "stdio.h"
fun(int x)
{if(x/2>0)fun(x/2);
printf("%d",x%2);}
main()
{ fun(20);
putchar(′\n′);}
A)11100
B)10100
C)10101
D)10110
正确答案: B
(47)阅读如下程序段,则执行后程序的输出结果是
#include <stdio.h>
main()
{structa{int x; int y;}num[2]={{20,5},{6,7}};
printf("%d\n",num[0].x/num[0].y*num[1].y);}
A)0
B)28
C)20
D)5
正确答案: B
(48)阅读程序段,则执行后的输出结果为
#include "stdio.h"
typedef union{ long x[2];
int y[4];
char z[8];} atx;
typedef struct aa{ long x[2];
int y[4];
char z[8]; } stx;
main()
{printf("union=%d,struct aa=%d\n",sizeof(atx),sizeof(stx));}
A)union=8,struct aa=8
B)union=8,struct aa=24
C)union=24,struct aa=8
D)union=24,struct aa=24
正确答案: B
(49)阅读下列程序段
#include "stdio.h"
typedef struct aa
{ int a;
struct aa *next; } M;
void set(M *k,int i,int *b)
{ int j,d=0;
for(j=1;j<i;j++)
{ k[j-1].next=&k[j];
k[j-1].a=b[d++]; }
k[j].a=b[d]; }
main()
{ M k[5],*p;
int d[5]={23,34,45,56,67};
set(k,5,d);
p=k+1;
printf("%d\n",table); }
则下面的表达式在table处,能使程序执行后,打印输出数据45的是
A)p->next->a
B)++p->a
C)(*p).a++
D)p++->a
正确答案: A
(50)阅读下面程序,程序实现的功能是(a123.txt在当前盘符下已经存在)
#include "stdio.h"
void main()
{FILE *fp;
int a[10],*p=a;
fp=fopen("a123.txt","w");
while( strlen(gets(p))>0 )
{ fputs(a,fp);
fputs("\n",fp);}
fclose(fp);}
A)从键盘输入若干行字符,按行号倒序写入文本文件a123.txt中
B)从键盘输入若干行字符,取前2行写入文本文件a123.txt中
C)从键盘输入若干行字符,第一行写入文本文件a123.txt中
D)从键盘输入若干行字符,依次写入文本文件a123.txt中
正确答案: D