77范文网 - 专业文章范例文档资料分享平台

C语言程序设计学习与实践指导(源代码)(8)

来源:网络收集 时间:2019-06-11 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

{ scanf(\【2】 ); } outone (int *b)

{ printf(\【3】 ); } main() { int *p;

getone(&p); assone(p); outone(p); }

18.下列程序的输出结果是 【1】 。

#define MAX(a,b) a>b #define EQU(a,b) a==b #define MIN(a,b) a

main() { int a=5,b=6; if(MAX(a,b)) printf(\); if(EQU(a,b)) printf(“EQU\\n”); if(MIN(a,b)) printf(\

11.2 例题分析与解答

1.以下程序的输出结果是( )。

struct HAR {

int x,y;

struct HAR *p; }h[2]; main() {

h[0].x=1; h[0].y=2; h[1].x=3;

h[1].y=4;

h[0].p=&h[1];h[1].p=h;

printf(\ }

2.以下程序的输出结果是( )。

union myun {

struct {

int x,y,z; }u; int k; }a; main() { a.u.x=4; a.u.y=5; a.u.z=6; a.k=0;

printf(%d\\n\ }

5.下面程序的输出结果为( )。

struct st { int x; int *y; }*p;

int dt[4]={10,20,30,40};

struct st aa[4]={ 50,&dt[0],60,&dt[1],70,&dt[2],80,&dt[3] }; main()

{ p=aa;

printf(\ printf(\ printf(\*p->y)); }

11.3 测试题

11.3.1 选择题

3.若有以下说明和语句,则值为6的表达式是( )。

struct st

{ int n;

struct st *next; };

struct st a[3],*p;

a[0].n=5; a[0].next=&a[1]; a[1].n=7; a[1].next=&a[2]; a[2].n=9; a[2].next=\\'\\\\0\\';

p=&a[0];

4.已知字符0的ASCII代码值的十进制数为48,且数组的第0个元素在低位,以下程序的输出结果是( )。

main()

{ union { int i[2]; long k; char c[4]; } r,*s=&r;

s->i[0]=0x39; s->i[1]=0x38; printf(\}

5.以下程序的输出结果是( )。

typedef union { long x[2]; int y[4]; char z[8]; } MYTYPE; MYTYPE them; main()

{ printf(\

6.以下程序的输出结果是( )。

struct st

{ int x; int *y; } *p;

int dt[4]={10,20,30,40};

struct st aa[4]={50,&dt[0],60,&dt[0],60,&dt[0],60,&dt[0],}; main() { p=aa;

printf(\ printf(\ printf(\*p->y)); }

7.以下程序的输出结果是( )。

typedef union { long i; int k[5]; char c; } DATE; struct date { int cat; DATE cow; double dog; } too; DATE max;

main()

{ printf(\

11.3.2 填空题

1.以下MIN 函数的功能是:在查找带有头结点的单向链表中,结点数据域的最小值作为函数值返回,请填空。

struct node { int data; struct node *next;

};

int MIN(struct node *first) { struct node *p; int m;

p=first->next; m=p->data;

for(p=p->next; p!='\\0'; p= 【1】 ) if( 【2】 ) m=p->data;

return m; }

2.函数creat用来建立一个带头结点的单向链表,新产生的结点总是插在链表的末尾,单向链表的头指针作为函数值返回。请填空。

#include \struct list

{ char data;

struct list *next;

} ;

struct list *creat() { struct list *h,*p,*q;

char ch ;

h=_____malloc(sizeof( 【1】 )); p=q=h;

ch=getchar();

while(ch!='?')

{ p= 【2】 malloc(sizeof( 【3】 )); p->data=ch; q->next=p; q=p;

ch=getchar(); }

p->next='\\0'; 【4】 ;

3.以下程序建立了一个带有头结点的单向链表,链表结点中的数据通过键盘输入,当输入数据为–1时,表示输入结束(链表头结点的 data 域不放数据,表空的条件是ph->next==NULL)。请填空。

#include struct list

{ int data;

struct list *next;}; 【1】 creatlist()

{ struct list *p,*q,*ph;

int a;

ph=(struct list *)malloc(sizeof(struct list));

p=q=ph;

printf(\ scanf(\ while(a!=-1)

{ p=(struct list *)malloc(sizeof(struct list)); p->data=a; q->next=p; 【2】 =p; scanf(\ }

p->next='\\0'; return(ph); }

main()

{

struct list *head; head=creatlist(); }

}

4.字符'0'的ASCII码的十进制数为48,且数组的第0个元素在低位,则以下程序的输出结果是 【1】 。

#include main( ) { union { int i[2]; long k; char c[4]; }r,*s=&r; s->i[0]=0x39; s->i[1]=0x38;

printf(\ }

12.2 例题分析与解答

2.以下程序用来统计文件中字符个数,请填空。

#include\ main()

{ FILE *fp;

long num=0L;

if((fp=fopen(\ { pirntf(\ exit(0); }

while(______) { fgetc(fp); num++;

}

printf(\ fclose(fp); }

3.下面的程序执行后,文件test.txt中的内容是( )。

#include\

void fun(char *fname,char *st) { FILE *myf;

int i;

myf=fopen(fname,\ for(i=0;i

main()

{ fun(\ fun(\ }

4.以下程序段打开文件后,先利用 fseek 函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度,请填空。

FILE *myf; long f1;

myf=______(\

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库C语言程序设计学习与实践指导(源代码)(8)在线全文阅读。

C语言程序设计学习与实践指导(源代码)(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/652983.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: