当前位置:编程学习 > C/C++ >>

C++学生成绩管理系统

答案:

提前申明这是从问问中搜索到的,并非原创:

#include <iostream>
using namespace std;
class stuhandle
{
private:
 char name[10];
 int stunumber[10];
protected:
 char subject[9];
 int score[9];
public:
 void addstu()
 {
  /*我不知道你的信息具体是什么这里就只添加姓名、学号、科目和分数。*/
  int i,n;
  for(i=1;i<10;i++)
  {
   cout<<"Please input the "<<i<<" students' name:"<<endl;
   cin>>name[i];
            cout<<"Please input the "<<i<<" students' number:"<<endl;
   cin>>stunumber[i];
   for(n=1;n<9;n++)
   {
    cout<<"Please input the "<<i<<" students' subject:"<<endl;
    cin>>subject[n];
    cout<<"Please input the "<<i<<" students' score:"<<endl;
    cin>>score[n];
   }
  }
 }
 void deletestu()
 {
  cout<<"Please input the student's name you wanna delete:"<<endl;
  char na;
  cin>>na;
  int i,n;
  for(i=1;i<10;i++)
  {
   if(name[i]==na)
   {
    name[i]=NULL;
    stunumber[i]=NULL;
   }
   for(n=1;n<9;n++)
   {
    subject[n]=NULL;
    score[n]=NULL;
   }
   break;
  }
 }
 void change()
 {
  cout<<"Please input the student's name you wanna change:"<<endl;
  char ch;
  cin>>ch;
  cout<<"Which information you wanna change?"<<endl;
  cout<<"(1)学号: (2)分数: "<<endl;
  int i,n;
  cin>>i;
  switch(i)
  {
  case 1:
   cout<<"Please input the new student number:"<<endl;
   int sn;
      cin>>sn;
   for(n=1;n<10;n++)
   {
    if(ch==name[n])
    {
     stunumber[n]=sn;
    }
    break;
   }
   break;
  case 2:
   cout<<"Please input the subject you wanna change:"<<endl;
   char sub,scoren;
   cin>>sub;
   cin>>scoren;
   for(n=1;n<9;n++)
   {
    if(sub==subject[n])
    {
     score[n]=scoren;
    }
    break;
   }
   break;
  default:
   cout<<"No such function!"<<endl;
  }
 }
 void search(char na)
 {

  cin>>na;
  int n;
  for(n=1;n<10;n++)
  {
   if(na==name[n])
   {
    cout<<"The Student number is :"<<stunumber[n]<<endl;
    cout<<"The Student number is :"<<subject[n]<<endl;
    cout<<"The Student number is :"<<score[n]<<endl;
   }
   break;
  }
 }
 void search(int num)
 {
  cin>>num;
  int n;
  for(n=1;n<10;n++)
  {
   if(num==name[n])
   {
    cout<<"The Student number is :"<<name[n]<<endl;
    cout<<"The Student number is :"<<subject[n]<<endl;
    cout<<"The Student number is :"<<score[n]<<endl;
   }
   break;
  }
 }
 void statistics(char subject,float lowscore,float highscore)
 {
 }
 void sort(char name,char subjcet)
 {
 }
};
int main()
{
 int i;
 stuhandle student;
 while(true)
 {
  cout<<"(1)信息维护: (2)信息查询: (3)成绩统计: (4)排序:"<<endl;
     cin>>i;
  switch(i)
  {
  case 1:
   cout<<"(1)添加:(2)删除:(3)修改:"<<endl;
   cin>>i;
   switch(i)
   {
   case 1:
    student.addstu();
    break;
   case 2:
    student.deletestu();
    bre

上一个:C++控件的CAPTION问题。
下一个:C++语言的难学吗?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,