学生选修课程系统设计
发布网友
发布时间:2022-05-05 04:05
我来回答
共2个回答
热心网友
时间:2022-06-29 05:13
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
typedef struct subjects
{
int num;
char na[10];
char teacher[20];
char wtime[10];
char ttime[10];
int score;
struct subjects *next;
}SUB;
SUB *create_form()
{
SUB *head,*tail,*p;
int num,score;
char na[10],teacher[20],wtime[10],ttime[10];
head=tail=NULL;
printf(" 输入选课程信息,以6个0结束:\n");
printf(" 课程代码 课名 任教老师 上课星期 上课时间 学分\n");
scanf("%d%10s%14s%10s%8s%6d",&num,&na,&teacher,&wtime,&ttime,&score);
while(num!=0)
{
p=(SUB*)malloc(sizeof(SUB));
p->num;
strcpy(p->na,na);
strcpy(p->teacher,teacher);
strcpy(p->wtime,wtime);
strcpy(p->ttime,ttime);
p->score=score;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d%s%s%s%s%d",&num,&na,&teacher,&wtime,&ttime,&score);
}
tail->next=NULL;
return head;
}
void savefile(SUB*head)
{
SUB *p;
FILE *fp;
fp=fopen("subjects.txt","w");
fprintf(fp,"欢迎进入东华理工大学2008-2009学年选修课系统(4-13)\n");
fprintf(fp,"课程代码 课名 任教老师 上课星期 上课时间 学分\n");
for(p=head;p;p->next)
fprintf(fp,"%6d%10s%14s%10s%8s%6d",p->num,p->na,p->teacher,p->wtime,p->ttime,p->score);
fclose(fp);
}
void prin(SUB *head)
{
SUB *p;
if (head==NULL)
{
printf("没有选修课程记录!\n");
return;
}
printf("欢迎进入东华理工大学2008-2009学年选修课系统(4-13)\n");
printf("课程代码 课名 任教老师 上课星期 上课时间 学分\n");
for(p=head;p;p->next)
printf("%6d%10s%16s%12s%12s%d",p->num,p->na,p->teacher,p->wtime,p->ttime,p->score);
}
SUB *inset(SUB *head)
{
SUB *ptr,*ptr2,*subj;
char ch, ch1;
printf("是否进行插入课程,如果需要插入请按回车建,不进行按空格结束!\n");
ch=getchar();
while(ch!=' '){
subj=(SUB*)malloc(sizeof(SUB));
ptr=subj;
printf(" 输入要插入的课程信息:\n");
scanf("%d%s%s%s%s%d",subj->num,subj->na,subj->teacher,subj->wtime,subj->ttime,subj->score);
if(head==NULL){
head=ptr;
head->next=NULL;
}
else{
for(ptr2=head;ptr2;ptr2=ptr2->next)
if(ptr2->next==NULL){
ptr2->next=subj;
subj->next=NULL;
break;
}
ch='a';
}
printf("继续请按回车建,结束请按空格:\n");
ch1=getchar();
ch=getchar();
}
return head;
}
SUB *del(SUB *head)
{
SUB*p1,*p2;
char ch,ch1;
int num;
printf("是否进行课程删除,要删除请按回车键,不进行请按空格:\n");
ch=getchar();
while(ch!=' ')
{
printf("输入要删除的课程代码:\n");
scanf("%d",&num);
if(head->num==num){
p2=head;
head=head->next;
free(p2);
}
if(head==NULL)
return NULL;
p1=head;
p2=head->next;
while(p2!=NULL){
if(p2->num==num){
p1->next=p2->next;
free(p2);
}
else
p1=p2;
p2=p1->next;
}
printf("继续删除请按回车键,结束请按空格:\n");
ch1=getchar();
ch=getchar();
}
return head;
}
typedef struct student
{
int number;
int classes;
char chinesename[16];
char title [5][12];
struct student *other;
}STU;
void scanf_form(SUB *head)
{
int i,count,number,classes;
char ch,title[3][12],chinesename[16];
scanf("%d%d%16s",&number,&classes,&chinesename);
for(i=0;i<5;i++)
{
scanf("%s",&title[i]);
count++;
if(count==3)
{
ch=getchar();
if(ch!=' ')
{title[3][12]='0';
title[4][12]='0';
i=5;
ch='a';
}
}
if(count==4)
{
ch=getchar();
if(ch!=' ')
{title[4][12]='0';
i=5;
ch='a';
}
}
for(i=0;i<5;i++)
{
if(strcmp(title[i][12],head->na)!=0 && title[i][12]!='0')
{ printf("你输入的课程名不正确,请从新输入:\n");
scanf_form();
}
}
}
}
STU *study_form(SUB*head)
{
STU *hand,*tall,*q;
int i;
char ch,ch1;
hand=tall=NULL;
printf("输入你个人信息,及选修的课名,以4个0结束:\n");
printf("注:每个学生至少选修3门课,大于3门时按回车键继续,空格结束:\n");
scanf_form();
while(number!=0)
{
q=(STU*)malloc(sizeof(STU));
q->number=number;
q->classes=classes;
strcpy(p->chinesename,chinesename);
for(i=0;i<5;i++)
strcpy(p->title[i],title[i][12]);
if(hand=NULL)
hand=q;
else
tall->other=q;
tall=q;
scanf_form();
for(i=0;i<5;i++)
{
if(strcmp(title[i][12],head->na)!=0&&titli[i][12]!='0')
{ printf("你输入的课程名不正确,请从新输入:\n");
scanf_form();
}
}
tall->other=NULL;
return hand;
}
}
void savefiles(STU*hand)
{
STU *q;
FILE *fq;
fq=fopen("studennt.txt","w");
fprintf(fq, "学生选课信息表:\n");
for(q=hand;q;q=q->other)
fprintf(fq,"%16d%10d%16s%16s%16s%16s%16s%16s",q->number,q->classes,q->chinesename,q->title[0],q->title[1],q->title[2],q->title[3],q->title[4]);
fclose(fq);
}
void prins(STU*hand)
{
STU *q;
if(head==NULL)
{
printf("没有学生选课信息记录!\n");
return;
}
printf("学生选课信息一览表:\n");
printf("学号 班级 姓名 课名 :\n");
for(q=hand;q;q->number)
printf("%16d%10d%16s%16s%16s%16s%16s%16s",q->number,q->classes,q->chinesename,q->title[0],q->title[1],q->title[2],q->title[3],q->title[4]);
}
STU *intserts(SUB*head,STU *hand)
{
STU *prt,*prt2,*stuj;
int i;
char ch,ch1;
printf("是否要进行插入学生选课信息,如果需要请按回车建,结束请按0:\n");
ch=getchar();
while(ch!=' ')
{
stuj=(STU*)malloc(sizeof(STU));
prt=stuj;
printf("输入要插入的学生选课信息:\n");
scanf_form();
if(hand==NULL)
{hand=prt;
hand->other=NULL;
}
else
{for(prt2=hand;prt2;prt2=prt2->other)
if(prt2->other==NULL)
{prt2->other=stuj;
stuj->other=NULL;
break;
}
ch='a';
}
printf("继续插入请按回车建,结束请按空格:\n");
ch1=getchar();
ch=getchar();
}
return hand;
}
STU *dells(STU *hand)
{
STU *q1,*q2;
char ch,ch1;
int number;
printf("是否进行学生选课信息删除,要删除请按回车建,不进行请按空格:\n");
ch=getchar();
while(ch!=' ')
{
printf("输入要删除的学号:\n");
scanf("%d",&number);
if(hand->number==number)
{
q2=hand;
hand=hand->other;
free(q2);
}
if(hand=NULL)
return NULL;
q1=hand;
q2=hand->other;
while(q2)
{if(q2->number==number)
{q1->other=q2->other;
free(q2);
}
else
q1=q2;
q2=q1->other;
}
printf("继续删除请按回车建,结束请按空格:\n");
ch1=getchar();
ch1=getchar();
}
return hand;
}
void search(STU*hand)
{
int a,number;
int t=1;
char type[10],ch,ch1;
STU *prt;
printf("是否进入查询,按回车键进入,空格结束:\n");
ch=getchar();
while(ch!=' ')
{
printf("请输入要查询的学号:\n");
for(prt=hand;prt;prt=prt->other)
{
if(number=prt->number)
{printf("%16d%10d%16s%16s%16s%16s%16s%16s",prt->number,prt->classes,prt->chinesename,prt->title[0],prt->title[1],prt->title[2],prt->title[3],prt->title[4]);
t=0;
}
if(t!=0)
printf("未找到!\n");
t=1;
}
printf("继续查找请按回车键,结束请按空格键:\n");
ch1=getchar();
ch=getchar();
}
}
void main()
{
SUB *head=create_form() ;
savefile(head);
prin(head);
head= inset(head);
head= del(head);
STU *hand=study_form(head);
savefiles(hand);
prins(hand);
hand=intserts(head,hand);
hand=dells(hand);
search(hand);
}
热心网友
时间:2022-06-29 05:14
对主页“index.html”进行针对搜索引擎的优化72设置主页默认语言编码为“中文简体”
1规范主页标题为“神话传说”
2对主页进行关键字优化,关键字为“课程编号,课程名称,课程性质”
2清除主页中不属于Dreamweaver的HTML注解,主页代码去除<!-- ImageReady Slices (页面效果图.psd) -->和<!-- End ImageReady Slices -->,各1分
对主页“index.html”进行链接优化33找到本地站点的主页“index.html”未添加链接的图片按钮“用户注册”、“忘记密码”和左下角的热区链接,对链接进行修正,均添加目标为FAQ.html的链接,每链接1分