下载此文档

计算机二级C语言上机试题100套及答案.doc


文档分类:资格/认证考试 | 页数:约327页 举报非法文档有奖
1/327
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/327 下载此文档
文档列表 文档介绍
上 机 题 库
第一部分  填空题
♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣
注意:。
1. 不得增行或删行,也不得更改程序的结构!
2. 请在程序下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣♣
1. 给定程序中,函数FUN的功能是:计算出带有头接点的单向链表中各结点数据域之和作为函数值返回。
#include  <>
#include  <>
#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; i<N; 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");
 }
}
2. 给定程序中,函数FUN的功能是:求出形参SS所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中工有M个字符串,且串长<N。
#include   <>
#include   <>
#define    M    5
#define    N    20
void fun(char  (*ss)[N])
{  int  i, j, k=0, n, m, len;
  for(i=0; i<M; i++)
  {  len=strlen(ss[i]);
   if(i==0) n=len;
   if(len>n) {
/**********************************found*********************************/
    n=len;    k=___1___;                             

计算机二级C语言上机试题100套及答案 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数327
  • 收藏数0 收藏
  • 顶次数0
  • 上传人aena45
  • 文件大小963 KB
  • 时间2021-08-20
最近更新