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

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

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

 

  2.阅读下列程序,写出程序的运行结果。IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  { char name[10];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float k1;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float k2;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  } a[2]={ {“zhang”, 100,70} ,{“wang”,70,80 } },* p=a;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  printf(“/nname:%s total=%f”,p ->name,p -> k1+p -> k2);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“/nname:%s total=%f”,a[l].name, a[1].k1+a[l].k2);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  “解”结构数组a 有两个元素,每个元素有三个成分:10个元素的字符数组和两个类型为float的成分k1、k2.结构指针变量p指向结构数组a的首元素。其中初始化使a的两个元素分别有值如下:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  a[0].name=“zhang”,a[0].k1= 100.0,a[0].k2=70.0,IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  a[1].name=“wang”,IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  a[l].k1=70.0, a[1].k2 =80.0.所以程序运行后输出:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  name:zhang total = 170.000000IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  name: wang total= 150.000000IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  3.阅读下列程序,写出程序的运行结果。IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { enum em { em1=3, em2=l, em3 };IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char * aa[] = {“AA”,“BB”,“CC”,“DD” } ;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“%s%s%s/n”,aa[em1],aa[em2], aa[em3] );IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  “解”由枚举类型测的定义知,枚举类型常量em1的值是3,枚举类型常量em2的值是1,枚举类型常量em3的值是2.所以程序运行后输出:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  DD BB CCIWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  1.用结构体存放下表中的数据,然后输出每人的姓名和实发工资( 基本工资+浮动工资-支出)。IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  姓名 基本工资(元) 浮动工资(元) 支出(元)IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  Li 220.00 300.00 90.00IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  Xia 370.00 180.00 60.00IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  Wang 620.00 0.00 70.00IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”程序定义struct person结构类型,包含人的姓名(<20个字符)、基本工资、浮动工资和支出,用这个struct person结构类型定义数组。程序首先输入人数n(<100),再输入n人的信息,最后输出各人的姓名和实发金额。程序如下:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  # define N 100IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  struct person {IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char name[20] ;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float base;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float ds;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float pay;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  } person[N], *p;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { int n;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char buf[120];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“输入%d个人的姓名、基本工资、浮动工资和支出 /n”, n);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for( p=person; pIWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, buf); strncpy( p -> name, buf, 19);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%f”, &d); p -> base=d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%f”,&d); p -> ds=d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%f”, &d ); p -> pay= d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(p = person; p< person+n; p++)IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“%s %.2f/n”,p-> name,P->base+p->ds-P -> pay);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  2.编一个程序,输入10个职工的编号、姓名、基本工资、职务工资,求出其中“基本工资十职务工资”最少的职工姓名并输出。IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”类似上一程序,直接给出程序如下:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  # define N 10IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  struct person {IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char no[10];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char name[20];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float base1;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  float base2;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  } person[N], *p, *minp;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { float d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char buf[120];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“输入%d个人的编号、姓名、基本工资、职务工资 /n”, N);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(p=person; pIWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, buf); strncpy(p -> no,buf,9);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, buf); strncpy( p -> name, buf, 19);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%f”, &d);p -> base1 =d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%f”,&d);p -> base2=d;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(minp=p=person; pIWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if (p -> basel+p -> base2< minp -> basel+ minp -> base2) minp =p;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“基本工资与职务工资和最少的职工是%s /n”,minp -> name);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“他的基本工资与职务工资和是%.2f /n”,minp -> basel+ minp -> base2);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  3.编一个程序,输入10个学生的学号、姓名、3门课程的成绩,求出总分最高的学生姓名并输出。IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  “解”类似上一程序,直接给出程序如下:IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

  # define N 10IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  struct stu {IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char no[10];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  char name[20];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  int score[3];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  } students[N],*p, *maxp;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  { char buf[120]; int maxs;IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  printf(“输入%d个学生的编号、姓名、三门课程成绩 /n”, N);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  for(p= students;p< students+N;p++) {IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, buf); strncpy(p -> no, buf, 9);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%s”, buf); strncpy( p -> name, buf,19);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  scanf(“%d%d%d”,&p -> score[O], &p -> score[1], &p -> score[2]);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  for(maxp= p =students, maxs=-1; p< students+N; p++)IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  if( p -> score[0] + p -> score[1]+p -> score[2]> maxs) {IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

  maxp=p;maxs=p ->score[0]+p -> score[1]+p ->score[2];IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

  printf(“最高总分的学生是%s他的总分是 %d /n”, maxp -> name, maxs);IWV湖南凯时app网_湖南凯时app本科_湖南凯时app报名_凯时app

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

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

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

 

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

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