#include #include #include #include #ifndef FUNCTION_H#define _FUNCITON_H_typedef struct student{ char nameStudent[10]; int numberSudent; int indexN; //已选数量 int elect[20]; //已选课题编号(多个) BOOL whetherNull;}STU;typedef struct pointLengthWidth{ int nx; int ny; int length; int width;}BOX;typedef struct couse{ int numberCouse; //编号 char nameCouse[10]; //课题 char nameTeacher[10];//指导老师 char addTeacher[10];//教研室地址 char nameMajorSelect[10];//可选此课题的专业 int numberSelect; //课程已选人数 int numberSelectMax; //课程人数上限 struct couse next;}COU;int N = 0;/*STU messagesStudent(STU s)void menu(BOX b)void menu2_2(BOX b)void menu2_1(BOX b)void drawBOX(BOX t)int inputInt()void changeCursor(int indexX, int indexY)void password()void changepassword()void cleanScreen()/STU* messagesStudent(STU s){ printf("\n请输入你的名字:"); scanf("%s",s->nameStudent); printf("\n请输入你的学号:"); scanf("%d",&s->numberSudent); s->whetherNull=TRUE; return s;}void menu(BOX b){ drawBOX(b); changeCursor(b.nx+b.length/3,b.ny+b.width/2-1); printf("1、student"); changeCursor(b.nx+b.length/3,b.ny+b.width/2); printf("2、teacher"); changeCursor(b.nx+b.length/3,b.ny+b.width/2+1); printf("3、安全退出"); changeCursor(10,1); printf("**学生选题管理系统***"); changeCursor(b.nx,b.ny+b.width+2);}void menu2_2(BOX b){ drawBOX(b); changeCursor(b.nx,b.ny-1); printf("★ teacher ★"); changeCursor(b.nx+b.length/3,b.ny+3); printf("1、载入文件"); changeCursor(b.nx+b.length/3,b.ny+4); printf("2、手动创建"); changeCursor(b.nx+b.length/3,b.ny+5); printf("3、添加"); changeCursor(b.nx+b.length/3,b.ny+6); printf("4、删除"); changeCursor(b.nx+b.length/3,b.ny+7); printf("5、修改"); changeCursor(b.nx+b.length/3,b.ny+8); printf("6、显示所有"); changeCursor(b.nx+b.length/3,b.ny+9); printf("7、储存数据"); changeCursor(b.nx+b.length/3,b.ny+10); printf("8、统计课题"); changeCursor(b.nx+b.length/3,b.ny+11); printf("9、返回上级"); changeCursor(b.nx+b.length/3,b.ny+13); printf("0、修改密码"); changeCursor(0,b.ny);}void menu2_1(BOX b){ drawBOX(b); changeCursor(b.nx,b.ny-1); printf("★ student ★"); changeCursor(b.nx+b.length/3,b.ny+3); printf("1、显示所有课题"); changeCursor(b.nx+b.length/3,b.ny+4); printf("2、显示可选课题"); changeCursor(b.nx+b.length/3,b.ny+5); printf("3、显示已选课题"); changeCursor(b.nx+b.length/3,b.ny+6); printf("4、选课题"); changeCursor(b.nx+b.length/3,b.ny+7); printf("5、退选"); changeCursor(b.nx+b.length/3,b.ny+8); printf("6、课题排序"); changeCursor(b.nx+b.length/3,b.ny+9); printf("7、储存信息"); changeCursor(b.nx+b.length/3,b.ny+10); printf("8、返回上级"); changeCursor(0,b.ny);}void drawBOX(BOX t){ int indexLength = 0; int indexWidth = 0; changeCursor(t.nx, t.ny); for ( indexLength = 0; indexLength <= t.length; indexLength++ ) { printf("★"); } for ( indexWidth = 0; indexWidth <= t.width; indexWidth++ ) { changeCursor(t.nx, t.ny+indexWidth); printf("★"); changeCursor(t.nx+t.length*2,t.ny+indexWidth); printf("★"); } changeCursor(t.nx, t.ny+indexWidth); for ( indexLength = 0; indexLength <= t.length; indexLength++ ) { printf("★"); } return TRUE;};int inputInt(){ int t; printf("请输入功能序号:"); scanf("%d",&t); return t;}void changeCursor(int indexX, int indexY){ COORD dwCursorPosition; HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE); if ( INVALID_HANDLE_VALUE == hOutput ) { printf("GetStdHandle error!\n"); return -1; } dwCursorPosition.X = indexX; dwCursorPosition.Y = indexY; if (!SetConsoleCursorPosition(hOutput, dwCursorPosition)) { printf("SetConsoleCursorPosition error!\n"); return -1; }}void cleanScreen(){ int i,j; for(i=0;i<80;i++) //length for(j=1;j<30;j++) //width { changeCursor(i,j); printf(" "); } changeCursor(0,0);}void changepassword(){ char word[15]; FILE passWordFile; if((passWordFile=fopen("password.txt","w+"))==NULL) { printf("**无法打开密码文件***\n"); exit(0); } printf("\n请输入新密码:"); scanf("%s",word); fprintf(passWordFile,"%s",word); printf("\n***恭喜!修改成功!***\n"); fclose(passWordFile);}void password() /** 输入密码 /{ char word[15]; FILE *passWordFile; char inputWord[20]; //存放密码的字符数组 char c; //临时存放一个字符 int i,j=1; // printf("****"); if((passWordFile=fopen("password.txt","r+"))==NULL) { printf("***无法打开密码文件***\n"); exit(0); } //printf("+++++++"); fscanf(passWordFile,"%s",word); printf("\n 请输入密码:\n "); while(j) { i=0; while ((c=getch()) != '\r')/**当输入的字符不是回车时,就存放进password[i]当输入回车时,结束循环*/ { inputWord[i] = c; i++; if(c!='\b') //输入内容不是退格时就显示 “*”号 { printf("*"); } else //输入内容是退格时 删除前一个 “*”号 { printf("\b \b"); } } inputWord[i]='\0';//标记结束 if(strcmp(inputWord,word)==0) { printf("\n 恭喜!密码正确!\n"); printf("\n 即将进入 请稍候...\n"); Sleep(1200); j=0; } else printf("密码错误!重新输入!\n"); } fclose(passWordFile);}#endif
1条回答
- qq_34226561 2016-03-22 15:52关注
#include
#include
#include
#include#ifndef FUNCTION_H
#define FUNCITON_H
typedef struct student
{
char nameStudent[10];
int numberSudent;
int indexN; //已选数量
int elect[20]; //已选课题编号(多个)
BOOL whetherNull;
}STU;
typedef struct pointLengthWidth
{
int nx;
int ny;
int length;
int width;
}BOX;
typedef struct couse
{
int numberCouse; //编号
char nameCouse[10]; //课题
char nameTeacher[10];//指导老师
char addTeacher[10];//教研室地址
char nameMajorSelect[10];//可选此课题的专业
int numberSelect; //课程已选人数
int numberSelectMax; //课程人数上限
struct couse next;
}COU;
int N = 0;
/
STU* messagesStudent(STU s)
void menu(BOX b)
void menu2_2(BOX b)
void menu2_1(BOX b)
void drawBOX(BOX t)
int inputInt()
void changeCursor(int indexX, int indexY)
void password()
void changepassword()
void cleanScreen()
*/
STU messagesStudent(STU *s)
{
printf("\n请输入你的名字:");
scanf("%s",s->nameStudent);
printf("\n请输入你的学号:");
scanf("%d",&s->numberSudent);
s->whetherNull=TRUE;
return s;
}void menu(BOX b)
{
drawBOX(b);
changeCursor(b.nx+b.length/3,b.ny+b.width/2-1);
printf("1、student");
changeCursor(b.nx+b.length/3,b.ny+b.width/2);
printf("2、teacher");
changeCursor(b.nx+b.length/3,b.ny+b.width/2+1);
printf("3、安全退出");
changeCursor(10,1);
printf("***学生选题管理系统***");changeCursor(b.nx,b.ny+b.width+2);
}
void menu2_2(BOX b)
{
drawBOX(b);
changeCursor(b.nx,b.ny-1);
printf("★ teacher ★");
changeCursor(b.nx+b.length/3,b.ny+3);
printf("1、载入文件");
changeCursor(b.nx+b.length/3,b.ny+4);
printf("2、手动创建");
changeCursor(b.nx+b.length/3,b.ny+5);
printf("3、添加");
changeCursor(b.nx+b.length/3,b.ny+6);
printf("4、删除");
changeCursor(b.nx+b.length/3,b.ny+7);
printf("5、修改");
changeCursor(b.nx+b.length/3,b.ny+8);
printf("6、显示所有");
changeCursor(b.nx+b.length/3,b.ny+9);
printf("7、储存数据");
changeCursor(b.nx+b.length/3,b.ny+10);
printf("8、统计课题");
changeCursor(b.nx+b.length/3,b.ny+11);
printf("9、返回上级");
changeCursor(b.nx+b.length/3,b.ny+13);
printf("0、修改密码");
changeCursor(0,b.ny);}
void menu2_1(BOX b)
{
drawBOX(b);
changeCursor(b.nx,b.ny-1);
printf("★ student ★");
changeCursor(b.nx+b.length/3,b.ny+3);
printf("1、显示所有课题");
changeCursor(b.nx+b.length/3,b.ny+4);
printf("2、显示可选课题");
changeCursor(b.nx+b.length/3,b.ny+5);
printf("3、显示已选课题");
changeCursor(b.nx+b.length/3,b.ny+6);
printf("4、选课题");
changeCursor(b.nx+b.length/3,b.ny+7);
printf("5、退选");
changeCursor(b.nx+b.length/3,b.ny+8);
printf("6、课题排序");
changeCursor(b.nx+b.length/3,b.ny+9);
printf("7、储存信息");
changeCursor(b.nx+b.length/3,b.ny+10);
printf("8、返回上级");changeCursor(0,b.ny);
}
void drawBOX(BOX t)
{
int indexLength = 0;
int indexWidth = 0;changeCursor(t.nx, t.ny); for ( indexLength = 0; indexLength <= t.length; indexLength++ ) { printf("★"); } for ( indexWidth = 0; indexWidth <= t.width; indexWidth++ ) { changeCursor(t.nx, t.ny+indexWidth); printf("★"); changeCursor(t.nx+t.length*2,t.ny+indexWidth); printf("★"); } changeCursor(t.nx, t.ny+indexWidth); for ( indexLength = 0; indexLength <= t.length; indexLength++ ) { printf("★"); } return TRUE;
};
int inputInt()
{
int t;
printf("请输入功能序号:");
scanf("%d",&t);
return t;
}void changeCursor(int indexX, int indexY)
{
COORD dwCursorPosition;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if ( INVALID_HANDLE_VALUE == hOutput )
{
printf("GetStdHandle error!\n");
return -1;
}dwCursorPosition.X = indexX; dwCursorPosition.Y = indexY; if (!SetConsoleCursorPosition(hOutput, dwCursorPosition)) { printf("SetConsoleCursorPosition error!\n"); return -1; }
}
void cleanScreen()
{
int i,j;
for(i=0;i<80;i++) //length
for(j=1;j<30;j++) //width
{
changeCursor(i,j);
printf(" ");
}
changeCursor(0,0);
}
void changepassword()
{
char word[15];
FILE passWordFile;
if((passWordFile=fopen("password.txt","w+"))==NULL)
{
printf("**无法打开密码文件***\n");
exit(0);
}
printf("\n请输入新密码:");
scanf("%s",word);
fprintf(passWordFile,"%s",word);
printf("\n***恭喜!修改成功!***\n");
fclose(passWordFile);
}
void password() /** 输入密码 /
{
char word[15];
FILE *passWordFile;
char inputWord[20]; //存放密码的字符数组
char c; //临时存放一个字符
int i,j=1;
// printf("****");
if((passWordFile=fopen("password.txt","r+"))==NULL)
{
printf("***无法打开密码文件***\n");
exit(0);
}
//printf("+++++++");
fscanf(passWordFile,"%s",word);
printf("\n 请输入密码:\n ");
while(j)
{
i=0;
while ((c=getch()) != '\r')/**当输入的字符不是回车时,就存放进password[i]当输入回车时,结束循环*/
{
inputWord[i] = c;
i++;
if(c!='\b') //输入内容不是退格时就显示 “*”号
{
printf("*");
}
else //输入内容是退格时 删除前一个 “*”号
{
printf("\b \b");
}
}
inputWord[i]='\0';//标记结束
if(strcmp(inputWord,word)==0)
{
printf("\n 恭喜!密码正确!\n");
printf("\n 即将进入 请稍候...\n");
Sleep(1200);
j=0;
}
else printf("密码错误!重新输入!\n");
}
fclose(passWordFile);
}
#endif
#ifndef DOCOURSE_H
#define DOCOURSE_Hvoid showOptional(COU*head);
void showSelected(COU*head);
COU* selectCourse(COU*head,STU s);
COU selectCourseBack(COU*head);
COU* outFileStudent(COU*head,STU s);
COU outFile(COU*head);
COU* modifyCourse(COU head) //修改
void deleteCourse(COU *head);
COU addCourse(COU head);
void view(COU *head);
COU loadStudent(COU head);
COU load(COU head);
void statisticsCourse(COU *head);
int lengthList(COU pHead);
COU* sortList(COU* pHead);
void exchange(COU *t1,COU *t2);
BOOL judgeCourse(COU *p1,COU *p2);
BOOL judgeList(COU *head,COU *p1);void showOptional(COU *head)
{
COU*p;
p=head;
if(head!=NULL){ printf("\n***可选择的课题信息***\n"); printf("编号 课程名 老师 教研地址 指定专业 是否被选\n"); } while(p!=NULL) { if(p->numberSelect==0) { printf("%d %s %s %s %s",p->numberCouse,p->nameCouse,p->nameTeacher,p->addTeacher,p->nameMajorSelect); printf(" 否\n"); p=p->next; } else p=p->next; }
}
void showSelected(COU*head)
{
COU*p;
p=head;
if(head!=NULL)
{
printf("\n***已选择的课题信息***\n");
printf("编号 课程名 老师 教研地址 指定专业 是否被选\n");
}
while(p!=NULL)
{
if(p->numberSelect==1)
{
printf("%d %s %s %s %s",p->numberCouse,p->nameCouse,p->nameTeacher,p->addTeacher,p->nameMajorSelect);
printf(" 是\n");
p=p->next;
}else p=p->next; }
}
COU* selectCourse(COU*head,STU s)
{
int select;
COU *p = head;
if(head==NULL)
{
printf("\n**警告:没有数据!***\n");
return head;
}
printf("\n请输入要选择的课题编号:");
scanf("%d",&select);
while(p->numberCouse!=select)
{
p=p->next;
if(p==NULL)
break;
}
if(p==NULL)
{
printf("\n***警告:没有此课题***\n");
return head;
}
if(p->numberCouse==select)
{
if(p->numberSelect==1)
{
printf("\nsorry,此课题已被选!");
return head;
}
else
{
p->numberSelect=1;
printf("***恭喜!选题成功!***\n");
s->elect[s->indexN]=select;
s->indexN++;
}
}
return head;
}COU* selectCourseBack(COU*head)
{
int select;
COU p = head;
if(head==NULL)
{
printf("\n**警告:没有数据!***\n");
return ;
}
printf("\n请输入要退选的课题编号:");
scanf("%d",&select);
while(p->numberCouse!=select)
{
p=p->next;
}
if(p->numberCouse==select)
{
if(p->numberSelect==0)
{
printf("\n未选择此课题!不用退选!\n");
return head;
}
else
{ p->numberSelect=0;
printf("***恭喜!退选成功!***\n");
}
}
else
printf("\n***警告:找不到相应数据!***\n");
return head;
}
COU* outFileStudent(COU*head,STU s)
{
FILE *output;
int i;
COU *p;
p=head;
if((output=fopen("outFileStudent.txt","a+"))==NULL)
{
printf("\n**警告!!!无法打开输出文件!***\n");
return head;
}
fprintf(output,"姓名:%s\n",s->nameStudent);
fprintf(output,"学号:%d\n",s->numberSudent);
fprintf(output,"***已选选课信息***\n");
/** 只需要储存此学生的选课信息 **/
while(p)
{
for(i=0;iindexN;i++)
{
if(p->numberCouse==s->elect[i])
{
fprintf(output,"%d\n",p->numberCouse);
fprintf(output,"%s\n",p->nameCouse);
fprintf(output,"%s\n",p->nameTeacher);
fprintf(output,"%s\n",p->addTeacher);
fprintf(output,"%s\n",p->nameMajorSelect);
fprintf(output,"%d\n",p->numberSelect);
}
}
p=p->next;
}
printf("\n恭喜!文件存储成功!\n");
fclose(output);
return head;
}COU* outFile(COU*head)
{
FILE output;
COU *p;
p=head;
if((output=fopen("infile.txt","w+"))==NULL)
{
printf("**警告!!!无法打开输出文件!!!***");
return 0;
}
while(p)
{
fprintf(output,"%d\n",p->numberCouse);
fprintf(output,"%s\n",p->nameCouse);
fprintf(output,"%s\n",p->nameTeacher);
fprintf(output,"%s\n",p->addTeacher);
fprintf(output,"%s\n",p->nameMajorSelect);
if(p->next==NULL)
fprintf(output,"%d",p->numberSelect);
else
fprintf(output,"%d\n",p->numberSelect);
p=p->next;
}
printf("\n恭喜!文件存储成功!\n");
fclose(output);
return head;
}
COU* modifyCourse(COU head) //修改
{
COU *p=head;
int tempt;
printf("请输入要修改的课题编号:\n");
scanf("%d",&tempt);
if(p==NULL)
{
printf("\n**警告:没有数据!***\n");
return head;
}
while(p->numberCouse!=tempt)
{
p=p->next;
}
if(p->numberCouse==tempt)
{printf("提示:(请输入修改数据)\n编号 课程名 老师 教研地址 指定专业\n"); scanf("%d",&p->numberCouse); scanf("%s",&p->nameCouse); scanf("%s",&p->nameTeacher); scanf("%s",&p->addTeacher); scanf("%s",&p->nameMajorSelect); printf("\n***修改成功!***\n"); return head; } else printf("警告:找不到相应数据!!!\n"); return head;
}
COU* init(COU head) //自行创建链表
{
int i;
COU *p,*s;
p=head;
if(head == NULL)
{
printf("**链表为空,创建数据!***\n\n");
}
else
{
printf("***已有数据,无法创建!***\n\n");
return head;
}
printf("请输入要创建的课题个数:\n ");
scanf("%d",&N);
printf("\n输入提示:\n编号 课程名 老师 教研地址 指定专业\n");
for(i=0;i {
if(i==0)
{
p=(struct couse*)malloc(sizeof(struct couse));
scanf("%d",&p->numberCouse);
scanf("%s",&p->nameCouse);
scanf("%s",&p->nameTeacher);
scanf("%s",&p->addTeacher);
scanf("%s",&p->nameMajorSelect);
p->numberSelect=0;
head=p;
}
else
{
s=(struct couse*)malloc(sizeof(struct couse));
scanf("%d",&s->numberCouse);
scanf("%s",&s->nameCouse);
scanf("%s",&s->nameTeacher);
scanf("%s",&s->addTeacher);
scanf("%s",&s->nameMajorSelect);
s->numberSelect=0;
p->next=s;
p=s;
}
}
p->next=NULL;
printf("***创建数据成功!***\n");
return head;
}void deleteCourse(COU head)
{
COU *p;
COU *q;
int tempt;
p=head;
q=head;
printf("请输入要删除的课题编号:\n");
scanf("%d",&tempt);
if(head==NULL)
{
printf("\n**警告:没有数据!***\n");
return ;
}
while(p->numberCouse!=tempt)
{
q=p;
p=p->next;
}
if(p->numberCouse==tempt)
{
if(q==head)
{
head=q->next;
free(q);
N--;
}
else
{
q->next=p->next;
free(p);
N--;
}
printf("\n***删除成功!***\n");
}
else
printf("警告:找不到相应数据!!!\n");
}
COU* addCourse(COU head)
{
COU *s,*p=head;
char c;
if(head==NULL)
{
printf("链表为空!创建新链表?\n Y or N?\n");
//printf("+++++");
c=getche();
//printf("***");
if(c=='y'||c=='Y')
{
s=(struct couse*)malloc(sizeof(struct couse));
printf("\n***输入数据***\n");
printf("输入提示:\n编号 课程名 老师 教研地址 指定专业\n");
scanf("%d",&s->numberCouse);
scanf("%s",&s->nameCouse);
scanf("%s",&s->nameTeacher);
scanf("%s",&s->addTeacher);
scanf("%s",&s->nameMajorSelect);
s->numberSelect=0;
s->next = NULL;
head = s;
printf("\n***创建数据成功!***\n");
return head;
}
else
return head;
}
while(p->next!=NULL)
{
p=p->next;
}
s=(struct couse*)malloc(sizeof(struct couse));
printf("\n请输入所插入数据:\n");
printf("输入提示:\n编号 课程名 老师 教研地址 指定专业\n");
scanf("%d",&s->numberCouse);
scanf("%s",&s->nameCouse);
scanf("%s",&s->nameTeacher);
scanf("%s",&s->addTeacher);
scanf("%s",&s->nameMajorSelect);
s->numberSelect=0;
s->next = NULL;
if(!judgeList(head,s))
{
printf("\n信息重复!添加失败!\n");
return head;
}
p->next = s;
printf("\n***添加数据成功***\n");
return head;
}/** 显示所有联系人 /
void view(COU head)
{
COU *p=head;
if(head==NULL)
{
printf("警告:链表为空!!!\n");
return ;
}
printf("\n编号 课程名 老师 教研地址 指定专业 是否被选\n");
while(p!=NULL)
{
printf("%d %s %s %s %s",p->numberCouse,p->nameCouse,p->nameTeacher,p->addTeacher,p->nameMajorSelect);
if(p->numberSelect==0)
printf(" 否\n");
else printf(" 是\n");
p=p->next;
}
}
COU loadStudent(COU *head)
{
FILE*fp;
COU *p;
COU *s;
if(head!=NULL)
{
/ 去掉此项不必要的提示 /
//printf("警告!!!目前已有数据,无法载入!!\n");
return head;
}
if((fp=fopen("infile.txt","r+"))==NULL)
{
printf("无法打开输入文件\n");
exit(0);
}
while(!feof(fp))
{
s=(COU*)malloc(sizeof(COU));
fscanf(fp,"%d",&s->numberCouse);
fscanf(fp,"%s",s->nameCouse);
fscanf(fp,"%s",s->nameTeacher);
fscanf(fp,"%s",s->addTeacher);
fscanf(fp,"%s",s->nameMajorSelect);
fscanf(fp,"%d",&s->numberSelect);
if(head==NULL)
{
s->next=NULL;
head=s;
p=head;
}
else
{
s->next=NULL;
p->next=s;
p=p->next;
}
}
printf("\n载入成功!\n");
fclose(fp);
return head;
}
COU* load(COU head)
{
FILE*fp;
COU *p;
COU *s;
if(head!=NULL)
{
printf("警告!!!目前已有数据,无法载入!!\n");
return head;
}
if((fp=fopen("infile.txt","r+"))==NULL)
{
printf("无法打开输入文件\n");
exit(0);
}
while(!feof(fp))
{
s=(COU)malloc(sizeof(COU));
fscanf(fp,"%d",&s->numberCouse);
fscanf(fp,"%s",s->nameCouse);
fscanf(fp,"%s",s->nameTeacher);
fscanf(fp,"%s",s->addTeacher);
fscanf(fp,"%s",s->nameMajorSelect);
fscanf(fp,"%d",&s->numberSelect);
if(head==NULL)
{
s->next=NULL;
head=s;
p=head;
}
else
{
s->next=NULL;
p->next=s;
p=p->next;
}
}
printf("\n载入成功!\n");
fclose(fp);
return head;
}
void statisticsCourse(COU *head)
{
COU *p=head;
int nCourse=0,nSelect=0;
while(p!=NULL)
{
nCourse++;
if(p->numberSelect==1)
nSelect++;
p=p->next;
}
printf("\n总课题数: %d",nCourse);
printf("\n已选课题数: %d",nSelect);
printf("\n未选课题数: %d\n",nCourse-nSelect);
if((nCourse-nSelect)<2)
printf("\n*提示:剩余课题数不足,请及时添加!***\n");
}
int lengthList(COU* pHead)
{
int len = 0;
COU* p = pHead;while(p != NULL) { len++; p = p->next; } return len;
}
COU* sortList(COU* pHead)
{
int i, j, t;
COU *p, *q;
int len = lengthList(pHead);for(i=0,p=pHead; i<len-1; ++i, p=p->next) { for(j=i+1,q=p->next; j<len; ++j,q=q->next) { if(p->numberCouse > q->numberCouse) { exchange(p,q); } } } printf("\n***排序成功!***\n"); return pHead;
}
void exchange(COU *t1,COU *t2)
{
COU t;
t.numberCouse = (*t2).numberCouse;
strcpy(t.nameCouse,(*t2).nameCouse);
strcpy(t.nameTeacher,(*t2).nameTeacher);
strcpy(t.addTeacher,(*t2).addTeacher);
strcpy(t.nameMajorSelect,(*t2).nameMajorSelect);
t.numberSelect = (*t2).numberSelect;t2->numberCouse = t1->numberCouse; strcpy((*t2).nameCouse,(*t1).nameCouse); strcpy((*t2).nameTeacher,(*t1).nameTeacher); strcpy((*t2).addTeacher,(*t1).addTeacher); strcpy((*t2).nameMajorSelect,(*t1).nameMajorSelect); t2->numberSelect = t1->numberSelect; t1->numberCouse = t.numberCouse; strcpy((*t1).nameCouse,t.nameCouse); strcpy((*t1).nameTeacher,t.nameTeacher); strcpy((*t1).addTeacher,t.addTeacher); strcpy((*t1).nameMajorSelect,t.nameMajorSelect); t1->numberSelect = t.numberSelect;
}
BOOL judgeCourse(COU *p1,COU *p2)
{
if(p1->numberCouse==p2->numberCouse||strcmp((*p1).nameCouse,(*p2).nameCouse)==0)
return FALSE;
else
return TRUE;//不重复
}
BOOL judgeList(COU *head,COU *p1)
{
COU *p=head;
if (p==NULL)
{
return TRUE;} while(p!=NULL) { //printf("33333333"); if(!judgeCourse(p,p1)) return FALSE;//重复 p=p->next; } return TRUE;//正常
}
#endif
#include "function.h"
#include "doCourse.h"int main()
{
COU *head=NULL;
STU *s;
char *word;
s->whetherNull=FALSE;//标记/** 边框1 /
BOX b1,b2_1,b2_2;
b1.nx=10;
b1.ny=5;
b1.length=10;
b1.width=5;
/ 边框2_2 /
b2_2.nx=45;
b2_2.ny=3;
b2_2.length=10;
b2_2.width=14;
/ 边框2_1 **/
b2_1.nx=45;
b2_1.ny=3;
b2_1.length=10;
b2_1.width=14;int t=0,index2=0,index1=0; t=0; while(t!=3) { index1 = 0; index2 = 0; menu(b1); //一级菜单 switch(inputInt()) { case 1: cleanScreen(); if(!s->whetherNull) s=messagesStudent(s); cleanScreen(); head=loadStudent(head); menu2_1(b2_1); while(index1!=100) { switch(inputInt()) { case 1: view(head);//显示所有课题 break; case 2: showOptional(head);//显示可选课题 break; case 3: showSelected(head);//显示已选课题 break; case 4: head=selectCourse(head,s);//选课题 此学生 break; case 5: head=selectCourseBack(head);//退选 break; case 6: head=sortList(head); break; case 7: head = outFileStudent(head,s);//存两份,一份原读取信息,一份学生选题信息outfilestudent head = outFile(head);//存入文件 break; case 8: index1=100; break; } } break; case 2: //教师 cleanScreen(); password(); cleanScreen(); menu2_2(b2_2); //二级菜单 while(index2!= 9) { switch(inputInt()) { case 1: head=load(head); //从文件载入 break; case 2: head=init(head); //自行创建链表(多个) break; case 3: head=addCourse(head);//添加(非空则创建) break; case 4: deleteCourse(head); //删 break; case 5: head=modifyCourse(head);//改 break; case 6: view(head); //显示所有 break; case 7: head = outFile(head); break; case 8: statisticsCourse(head); break; case 9: index2=9; break; case 0: changepassword(); break; default: printf("\n输入错误!\n"); break; } } break; case 3: t=3; break; } cleanScreen(); } return 0;
}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥30 python代码,帮调试
- ¥15 #MATLAB仿真#车辆换道路径规划
- ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
- ¥15 数据可视化Python
- ¥15 要给毕业设计添加扫码登录的功能!!有偿
- ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
- ¥15 微信公众号自制会员卡没有收款渠道啊
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条