2009年下半年全国计算机二级C++笔试答案
来源:优易学  2010-1-14 16:31:36   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  (15)请在以下程序第一行的下划线处填写适当内容,使程序能正确运行。
  〖16〗 ( double,double);
  main()
  { double x,y;
  scanf("%lf%lf",&x,&y);
  printf("%lf\n",max(x,y));
  }
  double max(double a,double b)
  { return(a>b ? a:b); }
  (16)以下程序运行后输入:3,abcde<回车>,则输出结果是 〖17〗
  #include
  move(char *str, int n)
  { char temp; int i;
  temp=str[n-1];
  for(i=n-1;i>0;i--) str[i]=str[i-1];
  str[0]=temp;
  }
  main()
  { char s[50]; int n, i, z;
  scanf("%d,%s",&n,s);
  z=strlen(s);
  for(i=1; i<=n; i++) move(s, z);
  (资料来源:东方教育网 http://www.eastedu.com.cn)
  printf("%s\n",s);
  }
  (17)以下程序运行后的输出结果是 〖18〗
  fun(int x)
  { if(x/2>0) fun(x/2);
  printf("%d ",x);
  }
  main()
  { fun(6); }
  (18)已有定义如下:
  struct node
  { int data;
  struct node *next;
  } *p;
  以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。请填空。
  p = (struct node *)malloc( 〖19〗 );
  (19)以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。
  #include
  #include
  main()
  { char s[80], d[80]; int i,j;
  gets(s);
  for(i=j=0;s[i]!='\0';i++)
  if( 〖20〗 ) { d[j]=s[i]; j++; }
  d[j]='\0';
  puts(d);
  }

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训