【编程题库】2010年C语言考试题库.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
【编程题库】2010年C语言考试题库

给定程序中,函数FUN的功能是:计算出带有头接点的单向链表中各结点数据域之和作为函数值返回。 #include stdio.h #include stdlib.h #define N 8 typedef struct list { int data; struct list *next; } SLIST; SLIST *creatlist(int *); void outlist(SLIST *); int fun( SLIST *h) { SLIST *p; int s=0; p=h-next; while(p) { /**********************************found*********************************/ s+= p-___1___; data /**********************************found*********************************/ p=p-___2___; next } return s; } main( ) { SLIST *head; int a[N]={12,87,45,32,91,16,20,48}; head=creatlist(a); outlist(head); /**********************************found*********************************/ printf(\nsum=%d\n, fun(___3___)); head } SLIST *creatlist(int a[ ]) { SLIST *h,*p,*q; int i; h=p=(SLIST *)malloc(sizeof(SLIST)); for(i=0; iN; i++) { q=(SLIST *)malloc(sizeof(SLIST)); q-data=a[i]; p-next=q; p=q; } p-next=0; return h; } void outlist(SLIST *h) { SLIST *p; p=h-next; if (p==NULL) printf(The list is NULL!\n); else { printf(\nHead ); do { printf(-%d, p-data); p=p-next; } while(p!=NULL); printf(-End\n); } } 给定程序中,函数FUN的功能是:求出形参SS所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中工有M个字符串,且串长N。 #include stdio.h #include string.h #define M 5 #define N 20 void fun(char (*ss)[N]) { int i, j, k=0, n, m, len; for(i=0; iM; i++) { len=strlen(ss[i]); if(i==0) n=len; if(lenn) { /**********************************found*********************************/ n=len; k=___1___; i } } for(i=0; iM; i++) if (i!=k) { m=n; len=strlen(ss[i]); /**********************************found*********************************/ for(j=___2___; j=0; j--) len ss[i][m--]=ss[i][j];

文档评论(0)

wuailuo + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档