fork download
  1. #include <stdio.h>
  2. typedef struct date
  3. {
  4. int year;
  5. int month;
  6. int day;
  7. }DATE;
  8. typedef struct student
  9. {
  10. long studentID; /* 学号 */
  11. char studentName[10]; /* 姓名 */
  12. char stuGender; /* 性别 */
  13. DATE birthday; /* 出生日期 */
  14. int score[4]; /* 4门课程的成绩 */
  15. }STUDENT;
  16. int main(void)
  17. {
  18. int i, j, sum[30];
  19. STUDENT stu[30] = {{100310121,"王刚",'M',{1991,5,19},{72,83,90,82}},
  20. {100310122,"李小明",'M',{1992,8,20},{88,92,78,78}},
  21. {100310123,"王丽红",'F',{1991,9,19},{98,72,89,66}},
  22. {100310124,"陈莉莉",'F',{1992,3,22},{87,95,78,90}}
  23. };
  24. for (i=0; i<4; i++)
  25. {sum[i]=0;
  26. for(j=0;j<4;j++)
  27. {sum[i]=sum[i]+stu[i].score[j];}
  28.  
  29. printf("%10ld%8s%3c%6d/%02d/%02d%4d%4d%4d%4d%6.1f\n",
  30. stu[i].studentID,
  31. stu[i].studentName,
  32. stu[i].stuGender,
  33. stu[i].birthday.year,
  34. stu[i].birthday.month,
  35. stu[i].birthday.day,
  36. stu[i].score[0],
  37. stu[i].score[1],
  38. stu[i].score[2],
  39. stu[i].score[3],
  40. sum[i]/4.0);
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
 100310121  王刚  M  1991/05/19  72  83  90  82  81.8
 100310122李小明  M  1992/08/20  88  92  78  78  84.0
 100310123王丽红  F  1991/09/19  98  72  89  66  81.2
 100310124陈莉莉  F  1992/03/22  87  95  78  90  87.5