c语言程序设计课件时第8章.pptVIP

  • 6
  • 0
  • 约1.38万字
  • 约 58页
  • 2019-01-01 发布于福建
  • 举报
c语言程序设计课件时第8章

例 8.10 有一个结构体变量stu,内含学生学号、姓名和3门课的成绩。要求分别编写两个不同的函数输出学生的学号、姓名和3门课的成绩及总成绩。 #include stdio.h #include string.h #define FORMAT %5d%9s%8.1f%8.1f%8.1f struct student { int num; char name[20]; float score[3]; }; void pri1(struct student stt) { printf( num name score1 score2 score3 sumscore\n); printf(FORMAT,stt.num,stt.name,stt.score[0],stt.score[1],stt.score[2]); } void pri2(float xx[ ]) { float sum; sum=xx[0]+xx[1]+xx[2]; printf(%9.1f,sum); } main() { struct student stu={1001,LiMing,67.5,89.0,78.6}; pri1(stu); pri2(stu.score); } ⑶ 指向结构体类型变量的

文档评论(0)

1亿VIP精品文档

相关文档