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

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

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

 

  4.说明下列程序的功能。D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { int i,j ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float a[3][3],b[3][3],c[3][3],x;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(i=0;i<3;i++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(j=0;j<3;j++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { scanf(“%f”, &x); a[j]= x;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(i=0;i<3;i++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(j=0;j<3;j++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  {scanf(“%f”,&x);b[j]=x;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(i=0; i<3; i++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(j=0;j<3;j++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  c[j]=a[j]+ b[j] ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(i=0; i<3;i++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(j=0;j<3;j++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“%f”, c[j]);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

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

  “解”程序第一段的功能是按行顺序输入数组a 的元素。程序第二段的功能是按行顺序输入数组b的元素。程序第三段的功能是顺序累加数组a和数组b的对应元素,并将和存于数组C的对应元素中。最后,按行顺序输出数组C的全部元素。D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  1.编程序,输入单精度型一维数组 a[10] ,计算并输出 a数组中所有元素的平均值。D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”为了计算数组元素的平均值,首先要累计它的全部元素的和,然后除以数组元素的个数,即得数组元素的平均值。写成C程序如下:D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  { int i, n=10;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float s,a[10] ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“Enter %d numbers! /n”, n);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for( i=0;i< n; i++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  { scanf(“%f”,&s); a= s;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(s=0.0,i=0;iD0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  s+= a ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  s /=n;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“平均值是%.2f/n”, s);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  2.编程序,输入10个整数存入一维数组,再按逆序重新存放后再输出。D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”将数组的元素逆序重新存放,就是将数组的首尾对应元素两两交换。简单地可用两个游标变量i和j,i是前端元素的下标,j是后端元素的下标,交换以这两个变量值为下标的数组元素。开始时,i的值为0,j的值为末元素的下标。每次交换后,i增1,j减1.继续交换的D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  条件是iD0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  { int a[10], i,j,t,n=10;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“Enter %d numbers! /n”, n);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  scanf(“%d”,&a );D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(i=0,j=n-1;iD0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  t= a; a=a[j] ;a[j] =t;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  printf(“%d/t”, a);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  3.编程序,输入两个字符串(<40个字符) ,连接后输出(不准用系统函数) .D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”将字符串s2连接到字符串s1的计算过程可分两个步骤完成。首先找到字符串s1的末尾,然后参照字符串s2,将字符串s2的全部有效字符逐一复制到字符串s1,最后在字符串s1的末尾接上字符率结束标记符。完整程序如下:D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  # define N 40D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { char s1[N] ,s2[N];D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  int i,j;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“Enter stringl!/n”);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”,s1);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“Enter string2! /n”);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, s2);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(i=0; sl!=‘/0’ ; i++) ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(j=0;s2[j]!=‘/0’ ;i++,j++)D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  so=s[j] ;D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  s1=‘/0’D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“sl=%s/n” ,sl);D0A湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

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

 

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

    湖南凯时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利来国际