?? main.cpp
字號:
/////頭文件//////////////////////////////////////////////////////////////////
#include <string.h>
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <iomanip.h>
#include <fstream.h>
#include <conio.h>
#include"subject.h"
////////////////////總菜單界面//////////////////
char face()
{
int k=0;
char a[3],c,i;
system("cls");
cout<<endl<<endl;
cout<<"\t\t\t\t 選修課小系統 \n\n"<<endl;
cout<<"\t\t☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n"
<<"\t\t \n"
<<"\t\t 操作方式: \n"
<<"\t\t 1.學生選課 \n"
<<"\t\t \n"
<<"\t\t 2.后臺管理 \n"
<<"\t\t \n"
<<"\t\t-------------------------------------------\n"<<endl;
while(1)
{
cout<<"\n\t\t請選擇登入方式: ";
cin>>a;
if(strlen(a)==1)
{
for(i='1';i<='2';i++)
{
c=i;
if(c==a[0])
return c;
}
}
cout<<"\n\n\t\t\t\t輸入有誤!\n"<<endl;
k++;
}
}
///////////////////學生選課界面///////////////////////
char student_face()
{
char A[10];
char b, i;
int k = 0;
system("cls");;
cout<<"\n\n\n"
<<"\t\t 學生選修課系統 \n"
<<"\t\t -----------------------------------------\n"
<<"\t\t \n"
<<"\t\t 操作方式: \n"
<<"\t\t 1.學生選課 \n"
<<"\t\t \n"
<<"\t\t 2.學生情況 \n"
<<"\t\t \n"
<<"\t\t 3.選課情況 \n"
<<"\t\t \n"
<<"\t\t 4.退出系統 \n"
<<"\t\t \n"
<<"\t\t\n"<<endl;
while(1)
{
cout<<"\t\t請選擇操作方式: ";
cin>>A;
if(strlen(A)==1)
{
for(i='1';i<='4';i++)
{
b=i;
if(b==A[0]) return b;
}
}
cout<<"\n\t\t\t\t輸入有誤!\n"<<endl;
k++;
}
}
char admin_face()
{
char A[10];
char b, i;
int k = 0;
system("cls");;
cout<<"\n\n\n"
<<"\t\t--------------------------------------------------\n"
<<"\t\t \n"
<<"\t\t 選修課系統后臺管理 \n"
<<"\t\t \n"
<<"\t\t 操作方式: \n"
<<"\t\t 1.增加學生 | 5.填寫成績 \n"
<<"\t\t 2.增加課程 | 6.選課情況 \n"
<<"\t\t 3.刪除學生 | 7.保存數據 \n"
<<"\t\t 4.刪除課程 | 0.退出系統 \n"
<<"\t\t \n"
<<"\t\t--------------------------------------------------\n"<<endl;
while(1)
{
cout<<"\t\t 請選擇操作方式: ";
cin>>A;
if(strlen(A)==1)
{
for(i='0';i<='9';i++)
{
b=i;
if(b==A[0])
return b;
}
}
cout<<"\n\t\t\t\t輸入有誤!\n"<<endl;;
k++;
if(k>2)
{
cout<<"錯誤輸入超過三次!\n";
exit(0);
}
}
}
/////////////////密碼檢查
void password()
{
int k=0,i;
char A[]="6666";
char B[10];
char a;
system("cls");
for(i=0;i<8;i++)
cout<<endl;
while(k<=2)
{
printf("\t\t請輸入密碼:");
i=0;
while(1)
{
a=getch();
if(a==13) break;
B[i]=a;
i++;
printf("*");
}
B[i]='\0';
if(strcmp(A,B)==0)
return;
else
{
k++;
cout<<"\n\n\t\t\t密碼輸入錯誤!請重新輸入!\n"<<endl;
}
if(k>=3)
{
system("cls");
cout<<"\n\n\t\t\t密碼錯誤超過三次!請退出.."<<endl;
exit(0);
}
}
}
struct subject_message
{
subject sub;
subject_message *Next;
};
int face_2_7(student_message *Y,subject_message *P);
////////////學生選課///////
int face_1_1(student_message *P,subject_message *X)
{
system("cls");
cout<<"\n\n\t\t\t\t學生選課操作"<<endl;
student_message *q=P->Next;
int i;
char N[20],M[20];
if(q!=NULL)
cout<<"\n\n\n\t\t所有學生名單如下:\n"<<endl;
else
{
cout<<"\n\n\n\t\t對不起,暫時沒有學生名單!請按任意鍵繼續.."<<endl;
return 1;
}
while(q)
{
q->stu.getname(N);
cout<<"\t\t\t\t"<<N;
cout<<endl;
q = q->Next ;
}
q = P->Next;
if(q==NULL)
return 1;
cout<<"\n\n\t\t 請輸入學生姓名:";
cin>>N;
i=0;
q=P->Next;
while(q)
{
q->stu.getname(M);
if(strcmp(N,M)==0)
i++;
q = q->Next;
}
int j=0,k=1;
if(i==0)
{
cout<<"\n\n\t\t沒有這個學生!! 請按任意鍵返回.."<<endl;
return 1;
}
else if(i>1)
{
cout<<"\n\n\t\t共找到"<<i<<"個姓名為"<<N<<"的學生"<<endl;
cout<<"\t\t選擇第幾個:";
cin>>k;
}
if(k>i||k<=0)
{
cout<<"\n\t\t\t輸入有誤!按任意鍵繼續"<<endl;
return 1;
}
q = P->Next;
j=0;
while(q)
{
q->stu.getname(M);
if(strcmp(N,M)==0)
j++;
if(j==k)
{
if(q->stu.retfact_course()>=q->stu.retmax_course())
{
cout<<"\n\t\t所選課程已滿!按任意鍵繼續"<<endl;
return 1;
}
else
{
subject_message *t=X->Next;
char N1[20];
system("cls");;
if(t!=NULL)
{
cout<<"\n\n\n\t\t所有課程如下:"<<endl;
cout<<"\n\t\t\t\t課程名稱\t\t 學分"<<endl;
}
else
{
cout<<"\n\n\n\t\t對不起,暫時沒有課程"<<endl;
return 1;
}
while(t)
{
t->sub.get_kname(N1);
cout<<"\t\t\t\t "<<N1<<setw(26-strlen(N1))<<t->sub.read_credit()<<endl;
t = t->Next ;
}
char N2[20];
cout<<"\n\t 輸入你所要選的課程 : ";
cin>>N2;
t = X->Next;
while(t)
{
t->sub.get_kname(N1);
if(strcmp(N1,N2)==0)
{
if(q->stu.findcourse(N2)==1)
{
cout<<"\n\t\t此課程你已選過了,不能再選.按任意鍵繼續"<<endl;
return 1;
}
t=X->Next;
char NA[20];
while(t)
{
t->sub.get_kname(NA);
if(strcmp(NA,N2)==0)
{
if(t->sub.retactivestudent()>=t->sub.retmaxstudent ())
{
cout<<"\n\t\t此課程已選滿,不能選.按任意鍵繼續"<<endl;
return 1;
}
}
t = t->Next;
}
q->stu.addcourse(N2,0.0);
cout<<"\n\n\t\t選課成功!按任意鍵繼續"<<endl;
return 1;
}
t = t->Next;
}
cout<<"\n\t\t沒有此課程!按任意鍵繼續"<<endl;
}
return 1;
}
q = q->Next;
}
return 1;
}
int face_1_2(student_message *P,subject_message *X) //學生情況
{
student_message *q=P->Next;
char N[20];
system("cls");
cout<<"\n\n\t\t\t\t學生情況操作"<<endl;
int i;
if(q!=NULL)
{
cout<<"\n\n\n\t\t所有學生選課信息如下:\n"<<endl<<endl;
cout<<"\t\t 姓名\t\t\t選課情況\n"<<endl;
}
else
{ cout<<"\n\n\n\t\t對不起,暫時沒有學生名單!!請按任意鍵繼續.."<<endl;
return 1;
}
while(q)
{
q->stu.getname(N);
cout<<"\t\t "<<N<<setw(25-strlen(N))<<" 已選 "<<q->stu.retfact_course()<<" 門課 "<<endl;
q = q->Next ;
}
char M[20];
cout<<"\n\t\t輸入要查看的學生姓名:";
cin>>M;
i=0;
q=P->Next;
while(q)
{
q->stu.getname(N);
if(strcmp(N,M)==0)
i++;
q = q->Next;
}
int j=0,k=1;
if(i==0)
{
cout<<"\n\t\t\t沒找到這個學生!!請按任意鍵繼續.."<<endl;
return 1;
}
else if(i>1)
{
cout<<"\n\t\t共找到"<<i<<"個姓名為"<<M<<"的學生"<<endl;
cout<<"\t\t選擇第幾個:";
cin>>k;
}
if(k>i||k<=0)
{
cout<<"\n\t\t\t輸入有誤!按任意鍵繼續.."<<endl;
return 1;
}
q = P->Next;
j=0;
q=P->Next;
while(q)
{
q->stu.getname(N);
if(strcmp(N,M)==0)
j++;
if(j==k)
{
system("cls");;
course *T=q->stu.retroot();
if(T==NULL)
{
cout<<"\n\n\n\t\t\t"<<N<<"你還沒有選課! 請按任意鍵繼續.."<<endl;
return 1;
}
if (T!=NULL)
T = T->Next;
cout<<"\n\n\n\t\t"<<N<<"同學你已選"<<q->stu.retfact_course()<<"門課,具體如下\n\n"<<endl;
cout<<"\t\t\t課程名稱\t\t成績\n"<<endl;
while(T)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -