学习代码

周一~周三 复习相关知识
周三~周四 码代码

include<stdio.h>

include<conio.h>

struct student
{
int num;
char cla[10];
char teacher[10];
int score;
}stu[5]={
{101,"操作系统","卢春燕",90},
{102,"数据结构","卢声凯",85},
{103,"数据库","袁秋慧",60},
{104,"C语言","洪伟",70},
{105,"高等数学","刘仪伟",88}
};
int main()
{
int ch,rec=5;
int cjsc(struct student stu[],int rec);
void show(struct student stu[],int);
void cjcx(struct student stu[],int);
printf(" 0---退出系统\n");
printf(" 1---学生选课删除\n");
printf(" 2---学生选课显示\n");
printf(" 3---学生选课查询\n");
scanf("%d",&ch);
switch(ch)
{
case 1:cjsc(stu,rec);break;
case 2:show(stu,rec);break;
case 3:cjcx(stu,rec);break;
default:printf("菜单选择错误!\n");
}
show (stu,rec);
printf("按任意键继续...");
getch();
return 0;
}
void show(struct student stu[],int rec)
{
struct studentp=stu;
printf("学号 课程名 教师 成绩 \n");
printf("-----------------------------------------------------\n");
for (p=stu;p<=stu+rec-1;p++)
{
printf("%d %7s%7s%9.0f\n",p->num,p->cla[10],p->teacher[10],p->score);
printf("-----------------------------------------------------\n");
}
printf(" 学生选课表 \n");
}
int cjsc(struct student stu[],int rec)
{
int i,xh;
struct student
p=stu;
printf("请输入学号:\n");
scanf("%d",&xh);
for (i=0;i<=rec-1;i++)
{
if (xhstu[i].num)
{
printf("学号 课程名 教师 成绩 \n");
printf("-----------------------------------------------------\n");
for (p=stu;p<=stu+rec-1;p++)
{
printf("%d %7s%7s%9.0f\n",p->num,p->cla[10],p->teacher[10],p->score);
printf("-----------------------------------------------------\n");
}
printf(" 学生选课表 \n");
rec--;
}
else
{
printf("查无此人!\n");break;
}
}
return rec;
}
void cjcx(struct student stu[],int rec)
{
while(1)
{
printf(" 学生课表查询\n");
struct student*p=stu;
int i,xh;
printf("请输入学号");
scanf("%d",&xh);
for (i=0;i<=rec-1;i++)
if (xh
stu[i].num)
{
*p=stu[i];
printf("学号 课程名 教师 成绩 \n");
printf("-----------------------------------------------------\n");
printf("%d %7s%7s%9.0f\n",p->num,p->cla[10],p->teacher[10],p->score);
getch();
return;
}
printf("查无此人!");
getch();

}

}

posted on 2020-04-30 15:08  joniky  阅读(476)  评论(0)    收藏  举报

导航