了解湖南/长沙凯时app资讯,从湖南凯时app网开始!湖南凯时app报名湖南凯时app本科
您当前的位置:凯时app > 湖南凯时app考前练习

凯时app“高级语言程序设计”经典习题及答案(32)

凯时app“高级语言程序设计”经典习题及答案(32)

 

  9.2 填充题CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  1.设有定义“# define F(N) 2*N”,则表达式 F(2+)的值是_____.CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”F(N)被定义成2*N,表达式F(2+3)被替换成2*2+3,其值是7.CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  2.设有下列程序:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # includeCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  main(int argc,int *argv[])CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { while( ——argc> 0) printf(“%s”,argv[argc]);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“/n”);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  假定上述程序编译连接成目标程序名为p.exe,如果输入如下的命令:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  P 123 AAA BBB ↓(其中的↓表示回车)CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  则输出结果是_____.CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”程序启动时,参数argc的值是4,由于循环条件是一即组>0,是先减1后判大于0,循环共进行三次,顺序输出argv[3],argv[2]和argv[1],即输出BBBAAAl23.CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  9.3 程序分析题CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  1.阅读下面程序,写出程序运行结果。CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # define PR(ar) printf(“%d,”, ar)CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  main()CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { int j,a[] ={1,3,5,7, 9,11,15}, * p= a+5;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(j=3; j; j——)CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  switch(j) { case 1:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  case 2: PR( * p++); break;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  case 3: PR(*(——p));CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“/n”);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”程序的宏定义PR以d格式输出参数的值和远号字符。程序给数组a 赋初值,并由指针p指向元素a[5].程序让j从3减至1,共循环三次。当j是3时,让p减1,并输出p所指元素的值9;当 j是2和1时,输出p所指的数组元素的值,并让p增1,顺序输出9和11.所以CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  程序输出:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  9,9,11CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  2.设下面的程序经编译连接后生成的目标程序名为: ABC.EXE,写出输入以下命令行后的输出:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  ABC FILE1 FILE2 ↓(其中的↓表示回车)CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # includeCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  main( int argc, char *argv[])CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { int i;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“%d /n”,argc);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(i=O;iCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“/n”);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”程序首先输出参数argv的值3,然后循环三次,顺序输出ABC、FILE1和FILE2,并回车CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  3CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  ABC FILE1 FILE2CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  3.读程序,写功能。CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # includeCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # includeCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  main(int argc, char *argv[])CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { FILE *fl,*f2;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char ch;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if(argc< 3)CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { printf(“Parameters missing! /n”);exit(0); }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if(((f1 =fopen(argv[1],“r”))== NULL) ||CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  ((f2=fopen(argv[2],“w”))== NULL))CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { printf(“Can not open file! /n”); exit(0); }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  while(!feof(f1)) fputc(fgetc(f1),f2);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  fclose(f1);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  fclose(f2);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”程序在argc小于3时,报告出错信息结束。当argc大于2时,以程序启动时的第一和第二参数为文件名打开文件,井用循环将第一参数的文件内容复制到第二参数的文件。CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  9.4 程序设计题CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  1.设计一个复制文本文件的程序,源文件名和目标文件名随程序启动执行命令输入。CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”直接写出程序如下:CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  # includeCUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  FILE *rfp,*wfp;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  int main( int argc, char *argv[])CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  {CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if( argc < 3) {CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“Parameters missing ! /n”); return 0 ;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if(((rfp= fopen(argv[1],“r”))== NULL) ||CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  ((=fopen(argv[2],“w”))== NLILL)) {CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“不能打开文件/n”);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  return 0;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  while( ! feof(rfp))CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  fputc( fgetc(rfp), wfp);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  fclose(wfp);fclose(rfp);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“程序结束/n”);CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  return l;CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  }CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

 CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

CUH湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

 

凯时app“高级语言程序设计”经典习题及答案(32)

    湖南凯时app网——致力于打造湖南凯时app网第一网,以努力服务于广大湖南凯时app学子、提供最全的湖南凯时app资讯为己任,发布湖南凯时app最新的新闻资讯,提供湖南凯时app专科湖南凯时app本科湖南凯时app报名湖南凯时app成绩查询等综合信息

 

湖南凯时app
相关文章
    无相关信息
湖南网站主页
湖南凯时app政策
凯时app30年大事
湖南凯时app专业
湖南凯时app问答
名家访谈
湖南凯时app故事
湖南凯时app院校
湖南凯时app大纲
凯时app复习方法
凯时app笔记串讲
凯时app应试技巧
湖南凯时app真题
湖南凯时app就业
湖南论文指导
湖南凯时app实践
湖南凯时app学位
凯时app成绩查询
凯时app考籍查询
凯时app学历查询


咨询QQ:137847917
13548661633(微信同号)

w66利来国际 w66利来国际 w66利来国际 w66利来国际 w66利来国际