#include<stdio.h> void main() { struct stu_type{ char num[15]; char name[10]; int age; int c; int math; int en; int sum; float ave; }stu1={"2011159113","张晓天",22,60,70,75},*p; p=&stu1; stu1.sum = stu1.c + stu1.math + stu1.en; stu1.ave = (float) stu1.sum /3; printf("学生学号\t姓名\t年龄\tC语言\t数学\t英语\t总分\t平均分\n"); printf("%-16s%s\t%d\t%d\t%d\t%d\t%d\t%5.1f\n",stu1.num,stu1.name,stu1.age,stu1.c,stu1.math,stu1.en,stu1.sum,stu1.ave) ; printf("%-16s%s\t%d\t%d\t%d\t%d\t%d\t%5.1f\n",(*p).num,(*p).name,(*p).age,(*p).c,(*p).math,(*p).en,(*p).sum,(*p).ave) ; printf("%-16s%s\t%d\t%d\t%d\t%d\t%d\t%5.1f\n",p->num,p->name,p->age,p->c,p->math,p->en,p->sum,p->ave) ; }
时间: 2024-10-12 13:24:46