학생 성적 관리 시스템 C++구현 코드
*(프로그램 머리 주석 시작)
*프로그램의 저작권 과 버 전 설명 부분
*Copyright(c)2011,연대 컴퓨터 학원 학생
* All rights reserved.
*파일 이름:
*저자:유강 파
*완료 일:2012 년 6 월 26 일
*버 전 번호:v.626
*퀘 스 트 및 해법 에 대한 설명 부분
*문제 설명:
C++로 학생 성적 관리 시스템 을 작성 합 니 다.
1.다음 과 같은 기능 을 실현 할 수 있다.
cout<<<<<<12307>★☆1.학생 성적 증가☆★★『12307』『12307』『12307』『12307』
cout<<<<<<12307>★★☆2.학생 성적 표시☆★★『12307』『12307』『12307』『12307』
cout<<<<<<<12307>★☆3.정렬 통계 성적☆★『12307』『12307』『12307』『12307』『12307』
cout<<<"〓〓〓〓〓〓〓★☆4.학생 성적 찾기☆★〓〓〓〓〓〓〓〓〓〓"
*
*/
# include <iostream>
# include <fstream>
# include <string.h>
#include <conio.h>// getch();
using namespace std;
//kkkkkkkkkkStudent kkkkkkkkkkk
class Student
{
public:
char name[20];
char Id[20];
int Cnum; //C++
int Mnum; //
int Enum; //
int sum; //
Student * Next;
void Input()
{
cout<<"\t\t :"; cin>>name;
cout<<"\t\t :"; cin>>Id;
cout<<"\t\t C++ :"; cin>>Cnum;
cout<<"\t\t :"; cin>>Mnum;
cout<<"\t\t :"; cin>>Enum;
sum=Cnum+Mnum+Enum;
}
void ReadFile(istream & in)
{
in>>name>>Id>>Cnum>>Mnum>>Enum>>sum;
}
void Show()
{
cout<<" :"<<name<<endl<<" :"<<Id<<endl<<"C++:"<<Cnum<<endl
<<" :"<<Mnum<<endl<<" :"<<Enum<<endl<<" :"<<sum<<endl<<endl<<endl;
}
};
//kkkkkkkkkStudentmassage kkkkkkkkkkkk
class Studentmassage
{
public:
Studentmassage();
~Studentmassage();
void ShowMenu();
void Find();
void Save();
void ModifyItem();
void RemoveItem();
void Swap(Student *,Student *);
void Sort();
//void Unpass();
int ListCount();
//void Average();
void Display()
{
for(Student * p=Head->Next;p!=End;p=p->Next)
p->Show();
cout<<" ! ……";
getch();
}
void AddItem()
{
End->Input();
End->Next=new Student;
End=End->Next;
cout<<" !"<<endl;
cout<<" ! ……";
getch();
}
private:
Student * Head,* End;
ifstream in;
ofstream out;
Student *FindItem(char * name)
{
for(Student * p=Head;p->Next!=End;p=p->Next)// ,
if(!strcmp(p->Next->name,name))return p;
return NULL;
}
Student *FindID(char * Id)
{
for(Student * p=Head;p->Next!=End;p=p->Next)// ,
if(!strcmp(p->Next->Id,Id))return p;
return NULL;
}
};
//kkkkkkkkkkkk kkkkkkkkkkkk
Studentmassage::Studentmassage()
{
Head=new Student;
Head->Next=new Student;
End=Head->Next;
in.open("sort.txt");
if(!in)
cout<<" , 。 。"<<endl;
else
{
while(!in.eof())
{
End->ReadFile(in);
if(End->name[0]=='\0')break;
End->Next=new Student;
End=End->Next;
}
in.close();
cout<<"\t\t !"<<endl;
}
}
//kkkkkkkkkkkk kkkkkkkkkkkk
Studentmassage::~Studentmassage()
{
Save();
for(Student * temp;Head->Next!=End;)
{
temp=Head->Next;
Head->Next=Head->Next->Next;
delete temp;
}
delete Head,End;
}
//kkkkkkkkkkkk kkkkkkkkkkkk
void Studentmassage::ShowMenu()
{
cout<<"********************************************************************************"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓〓 ☆ ☆ 〓〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓★★★★★ ★★★★★★★ ★★★★★〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 1. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 2. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 3. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 4. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 5. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 6. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 0. ☆ ★〓〓〓〓〓〓〓〓〓"<<endl;
cout<<"
\t\t
\t\t :";
}
//kkkkkkkkkkkk kkkkkkkkkkkk
void Studentmassage::Find()
{
char name[20] ,Id[10];
int x;
Student * p=NULL;
cout<<"
\t\t*********************************
";
cout<<"\t\t※ 1.
\t\t※ 2. ";
cout<<"
\t\t*********************************
:";
cin>>x;
switch(x)
{
case 1:{cout<<"\t\t :";cin>>name;
if(p=FindItem(name))
{
p->Next->Show();
cout<<" ! ……";
getch();
}
else
{
cout<<"\t\t !"<<'
'<<endl;
cout<<" ! ……";
getch();
}
}break;
case 2:
{
cout<<"\t\t :";cin>>Id;
if(p=FindID(Id))
{
p->Next->Show();
cout<<" ! ……";
getch();
}
else
{
cout<<"\t\t !"<<'
'<<endl;
cout<<" ! ……";
getch();
}
}break;
}
}
//kkkkkkkkkkkk kkkkkkkkkkkk
void Studentmassage::ModifyItem() //
{
char name[20];
Student * p=NULL;
cout<<"\t\t :";cin>>name;
if(p=FindItem(name))
{
cout<<"\t\t , !"<<endl;
p->Next->Input();
cout<<" !"<<endl;
cout<<" ! ……";
getch();
}
else
{
cout<<"\t\t !"<<endl;
cout<<" ! ……";
getch();
}
}
//kkkkkkkkkkkk kkkkkkkkkkkk
void Studentmassage::RemoveItem() //
{
char name[20];
Student * p=NULL,*temp=NULL;
cout<<"\t\t :"<<endl;cin>>name;
if(p=FindItem(name))
{
temp=p->Next;
p->Next=p->Next->Next;
delete temp;
cout<<"\t\t !"<<endl;
cout<<" ! ……";
getch();
}
else
{
cout<<"\t\t !"<<endl;
cout<<" ! ……";
getch();
}
}
//kkkkkkkkkkkkkkkkkkkkkkkk
void Studentmassage::Swap(Student *p1, Student *p2)// combox
{
Student *temp=new Student;
strcpy(temp->name,p1->name);
strcpy(temp->Id,p1->Id);
temp->Cnum=p1->Cnum;
temp->Mnum=p1->Mnum;
temp->Enum=p1->Enum;
temp->sum=p1->sum;
strcpy(p1->name,p2->name);
strcpy(p1->Id,p2->Id);
p1->Cnum=p2->Cnum;
p1->Mnum=p2->Mnum;
p1->Enum=p2->Enum;
p1->sum=p2->sum;
strcpy(p2->name,temp->name);
strcpy(p2->Id,temp->Id);
p2->Cnum=temp->Cnum;
p2->Mnum=temp->Mnum;
p2->Enum=temp->Enum;
p2->sum=temp->sum;
}
//kkkkkkkkkkkkkkkkkkkkkkkk
int Studentmassage::ListCount()// ,
{
if(! Head)
return 0;
int n=0;
for(Student * p=Head->Next;p!=End;p=p->Next)
{
n++;
}
return n;
}
//kkkkkkkkkkkkkkkkkkkkkkkk
void Studentmassage::Sort()//
{
cout <<"Sorting..."<<endl;
Student *p=NULL,*p1=NULL,*k=NULL;
int n=Studentmassage::ListCount();
if(n<2)
return;
for(p=Head->Next;p!=End;p=p->Next)
for(k=p->Next;k!=End;k=k->Next)
{
if(p->sum>k->sum)
{
Studentmassage::Swap(p,k);
}
}
cout <<" !"<<endl;
getch();
return;
}
//kkkkkkkkkkk kkkkkkkkkkkkk
void Studentmassage::Save()
{
out.open("sort.txt");
for(Student *p=Head->Next;p!=End;p=p->Next)
out<<p->name<<"\t"<<p->Id<<"\t"<<p->Cnum<<"\t"
<<p->Mnum<<"\t"<<p->Enum<<"\t"<<p->sum<<'
';
out.close();
}
//kkkkkkkkkkkk kkkkkkkkkkkk
int main()
{
int x,i=0;
bool quit=false;
cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§"<<endl;
for(i=0;i<3;i++)
cout<<"\t\t◎\t\t\t\t\t\t ◎"<<endl;
cout<<"\t\t◎★★★★【 】★★★★◎"<<endl;
for(i=0;i<3;i++)
cout<<"\t\t◎\t\t\t\t\t\t ◎"<<endl;
cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§
"<<endl;;
Studentmassage Grade;
cout<<" ……";
getch();
while(!quit)
{
system("cls");
Grade.ShowMenu();
cin>>x;
switch(x)
{
case 0:quit=true;break;
case 1:Grade.AddItem();break;
case 2:Grade.Display();break;
case 3:Grade.Sort();break;
case 4:Grade.Find();break;
case 5:Grade.RemoveItem();break;
case 6:Grade.ModifyItem();break;
}
}
return 0;
}

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.