C++과정 설계 의 학생 성적 관리 시스템

본 논문 의 사례 는 C+학생 성적 관리 시스템 의 구체 적 인 코드 를 공유 하여 여러분 께 참고 하 시기 바 랍 니 다.구체 적 인 내용 은 다음 과 같 습 니 다.

/*  :            :    、  、  ,  、  、    。
     10     。
             :     、  、  、    。
            、   、    、    。
             、     。
            、          、     。
                (90    )、    ,     。*/
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class student
{
 int num;
 char name[20];
 char class1[20];
 double chinese;
 double math;
 double english;
 double youxiu;//   
 double bujige;//    
 double sum;//   
 double aver1;//    
 
public:
 void set()
 {
 
 cout<<"\t    :";
 cin>>num;
 cout<<"\t    :";
 cin>>name;
  cout<<"\t    :";
 cin>>class1;
 cout<<"\t    :";
 cin>>chinese;
 cout<<"\t    :";
 cin>>english;
 cout<<"\t    :";
 cin>>math;
 }
 void show()
 {
 cout<<"      :"<<num<<endl;
 cout<<"      :"<<name<<endl;
 cout<<"      :"<<class1<<endl;
 cout<<"        :"<<chinese<<endl;
 cout<<"        :"<<math<<endl;
 cout<<"        :"<<english<<endl;
 }
 double ad(){return sum=chinese+english+math;}
 double aver()
 {
 aver1=(chinese+english+math)/3;
 return aver1;
 }
 friend void show();
 friend void search(); 
 friend void change(); 
 friend void add(); 
 friend void paixu();
 friend void del(); 
 
};
 void input();
 void show();
 void search(); 
 void change(); 
 void add(); 
 void paixu();
 void del(); 
 student s[100];
 int n=0;
 
int main()
{
 
 int select; 
 while(1)
 {
 system("cls");
 cout<<"\t ******************    ******************
"; cout<<"\t ************** **************
"; cout<<"\t *------------------------------------------*
"; cout<<"\t * 1―― *
"; cout<<"\t * 2―― *
"; cout<<"\t * 3―― *
"; cout<<"\t * 4―― *
"; cout<<"\t * 5―― *
"; cout<<"\t * 6―― *
"; cout<<"\t * 7―― *
"; cout<<"\t * 0―― *
"; cout<<"\t *------------------------------------------*
"; cout<<"\t (0--7):"; cin>>select; if(select==0) break; switch(select){ case 1: input(); // input system("pause"); break; case 2: show(); // show system("pause"); break; case 3: search(); // search system("pause"); break; case 4: change(); // change system("pause"); break; case 5: add(); // add system("pause"); break; case 6: paixu(); // add system("pause"); break; case 7: del(); // del system("pause"); break; system("pause"); default: cout<<" , !"<<endl; } } return 0; } void input() // { char sel; do { n++; cout<<"\t "<<n<<" :\t"<<endl; s[n].set(); cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); } void show() { cout<<left; // cout<<setw(10)<<" " <<setw(10)<<" " <<setw(13)<<" " <<setw(12)<<" " <<setw(12)<<" " <<setw(12)<<" " <<endl; for(int i=1;i<=n;i++) { cout<<setw(10)<<s[i].num <<setw(10)<<s[i].name <<setw(13)<<s[i].class1 <<setw(12)<<s[i].chinese <<setw(12)<<s[i].math <<setw(12)<<s[i].english<<endl; } cout<<endl; } void search()// { int a,b,i;char c[20]; cout<<" :"<<endl; cout<<" 1"<<endl; cout<<" 2"<<endl; cin>>a; switch(a) { case 1: {char sel; do{ cout<<" :"<<endl; cin>>c; for(i=1;i<=n;i++) if(strcmp(s[i].name,c)==0) {cout<<" :"<<endl; cout<<" :"<<s[i].num<<endl<<" :" <<s[i].name<<endl<<" :" <<s[i].class1<<endl<<" :" <<s[i].chinese<<endl<<" :" <<s[i].math<<endl<<" :" <<s[i].english<<endl; break; } else if(strcmp(s[i].name,c)!=0&&i==n) {cout<<" !"<<endl;break;} cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); break; } case 2: { char sel; do{ cout<<" :"<<endl; cin>>b; for(i=1;i<=n;i++) if(s[i].num==b) { cout<<" :"<<endl; cout<<" :"<<s[i].num<<endl<<" :" <<s[i].name<<endl<<" :" <<s[i].class1<<endl<<" :" <<s[i].chinese<<endl<<" :" <<s[i].math<<endl<<" :" <<s[i].english<<endl; break; } else if(s[i].num!=b&&i==n) {cout<<" ! !"<<endl;break;} cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); break;} default: cout<<" !"<<endl; } } void change() { { char sel; int d,i,e,f,g=0; do{ cout<<" :"<<endl; cin>>d; for(i=1;i<=n;i++) if(s[i].num==d) { cout<<" :"<<endl; cout<<" :"<<s[i].num<<endl<<" :" <<s[i].name<<endl<<" :" <<s[i].class1<<endl<<" :" <<s[i].chinese<<endl<<" :" <<s[i].math<<endl<<" :" <<s[i].english<<endl; e=1; break; } else if(s[i].num!=d&&i==n) {cout<<" ! !"<<endl; e=0;break;} while(e==1) { {cout<<" :"<<endl; cout<<" :1" <<'\t'<<" :2" <<'\t'<<" :3" <<'\t'<<" :4" <<'\t'<<" :5" <<'\t'<<" :6"<<endl; } cin>>f; switch(f) {case 1:cout<<"\t :"; cin>>s[i].num;break; case 2:cout<<"\t :"; cin>>s[i].name;break; case 3:cout<<"\t :"; cin>>s[i].class1;break; case 4:cout<<"\t :"; cin>>s[i].chinese;break; case 5:cout<<"\t :"; cin>>s[i].math;break; case 6:cout<<"\t :"; cin>>s[i].english;break; default:cout<<" , !"; cin>>f;} e=0; g=1; } if(g==1) { cout<<" !";} cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); } } void add() { char sel; do { n++; cout<<"
"<< n <<" :
"; cout<<"\t :"; cin>>s[n].num; cout<<"\t :"; cin>>s[n].name; cout<<"\t :"; cin>>s[n].class1; cout<<"\t :"; cin>>s[n].chinese; cout<<"\t :"; cin>>s[n].math; cout<<"\t :"; cin>>s[n].english; cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); } void paixu() { int a; cout<<" :"<<endl; cout<<"1. ;"<<endl <<"2. ;"<<endl <<"3. ;"<<endl; cin>>a; switch(a) { case 1: {int t=0; for(int i=0;i<n-1;i++) for(int j=0;j<n-i;j++) if(s[j].num>s[j+1].num) { t=s[j].num; s[j].num=s[j+1].num; s[j+1].num=t;} cout<<" :"<<endl; cout<<left; // cout<<setw(10)<<" " <<setw(10)<<" " <<setw(13)<<" " <<setw(12)<<" " <<setw(12)<<" " <<setw(12)<<" " <<endl; for(i=1;i<=n;i++) { cout<<setw(10)<<s[i].num <<setw(10)<<s[i].name <<setw(13)<<s[i].class1 <<setw(12)<<s[i].chinese <<setw(12)<<s[i].math <<setw(12)<<s[i].english<<endl;} } break; /* case 2: {double t; for(int i=0;i<n-1;i++) { for(int j=0;j>n-i-1;j++) { if(s[j].sum>s[j+1].sum) t=s[j].sum; s[j].sum=s[j+1].sum; s[j+1].sum=t; } } cout<<" :"<<endl; for(i=1;i<=n;i++) cout<<" :"<<s[i].num<<"\t"<<" :"<<s[i].name<<"\t"<<" :"<<s[i].class1<<"\t" <<" :"<<s[i].chinese<<"\t"<<" :"<<s[i].math<<"\t"<<" "<<s[i].english<<"\t "<<s[i]sum<<endl; cout<<endl; } break;*/ /* case 3: int t; for(int i=0;i<n-1;i++) { for(int j=0;j>n-1-i;j++) { if(s[j].aver()>s[j+1].aver()) t=s[j].aver(); s[j].aver()=s[j+1].aver(); s[j+1].aver()=t; } } cout<<" :"<<endl; for(i=0;i<n;i++) cout<<" :"<<s[i].num<<"\t"<<" :"<<s[i].name<<"\t"<<" :"<<s[i].class1<<"\t" <<" :"<<s[i].chinese<<"\t"<<" :"<<s[i].math<<" "<<s[i].english<<endl; cout<<endl; } break ; */ default: {cout<<" ! !"<<endl; cin>>a;} } } void del() { int j,i,k;char c[10],sel,y; do{ cout<<" :"<<endl; cin>>c; for(i=1;i<=n;i++) if(strcmp(s[i].name,c)==0) {cout<<" :"<<endl; cout<<" :"<<s[i].num<<endl <<" :"<<s[i].name<<endl <<" :"<<s[i].class1<<endl <<" :"<<s[i].chinese<<endl <<" :"<<s[i].math<<endl <<" :"<<s[i].english<<endl; cout<<" ?(y/n):"; cin>>y; if(y=='Y'||y=='y') { for(j=i;j<=n+1;j++) { s[j]=s[j+1]; } k=1; } else cout<<" !"<<endl; break; } else if(strcmp(s[i].name,c)!=0&&i==n) {cout<<" ! !"<<endl; k=0;break;} while(k==1) { if(y=='Y'||y=='y') cout<<" !"; n--; k=0; } cout<<" (Y/N):"; cin>>sel; }while(sel=='Y' || sel=='y' ); }
효과 그림:

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

좋은 웹페이지 즐겨찾기