diff --git a/任务七.c b/任务七.c new file mode 100644 index 0000000..f3a191d --- /dev/null +++ b/任务七.c @@ -0,0 +1,179 @@ +#include +#include +int i=0; +struct data + { + char num[10]; + char clas[10]; + char name[20]; + float grade1; + float grade2; + float grade3; + float total; + }; + struct data stu[100]; +int main() +{ + void menu(); + menu(); + } +void print(struct data a) +{ + printf("%s %s %s %3.1f %3.1f %3.1f %3.1f",a.num,a.clas,a.name,a.grade1,a.grade2,a.grade3,a.grade1+a.grade2+a.grade3); +} +void menu() +{ + void input(); + void delet(); + void select(); + void order(); + void output(); + printf(" 1.input\n"); + printf(" 2.delete\n"); + printf(" 3.select\n"); + printf(" 4.order\n"); + printf(" 5.output\n"); + printf(" 6.quit\n"); + printf("please input your option\n"); + int a; + scanf("%d",&a); + if(a==1) + { + input(); + } + else if(a==2) + { + delet(); + } + else if(a==3) + { + select(); + } + else if(a==4) + { + order(); + } + else if(a==5) + { + output(); + } + else printf("\n"); + + + } +void input() +{ + void menu(); + char a[5]; + printf("Id "); + scanf("%s",stu[i].num); + printf("class "); + scanf("%s",stu[i].clas); + printf("name "); + scanf("%s",stu[i].name); + printf("score1 "); + scanf("%f",&stu[i].grade1); + printf("score2 "); + scanf("%f",&stu[i].grade2); + printf("score3 "); + scanf("%f",&stu[i].grade3); + stu[i].total=stu[i].grade1+stu[i].grade2+stu[i].grade3; + printf("continue?(yes or no)\n"); + scanf("%s",a); + if(strcmp(a,"yes")==0) + { + i++; + input(); + } + else menu(); + } + void delet() + { + void menu(); + char a[10]; + char b[10]; + printf("请输入要删除的学生学号或者姓名 "); + scanf("%s",a); + struct data temp; + for(int j=0;j0) + { + temp=stu[j]; + stu[j]=stu[p]; + stu[p]=temp; + } + } + } + for(int j=0;j