| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 499 人关注过本帖
标题:学生信息管理程序
只看楼主 加入收藏
lzc8994375
Rank: 1
等 级:新手上路
帖 子:5
专家分:4
注 册:2012-5-21
结帖率:50%
收藏
已结贴  问题点数:15 回复次数:3 
学生信息管理程序
/*关键技术分析:编写字符串类、文件读写类、界面显示类等以及各相关接口类。
题目六:学生信息管理程序
设计要点:使用文本命令行界面设计学生信息管理程序;用文件形式存储班上学
生的信息表;能实现对学生信息增、删、改、查等功能。*/
#include<iostream>
#include<string>
using namespace std;
class student
{
  private:
      int number;
      char name[20];
      string sex;
      int age,telphone,QQ;
      int china;
      int english;
      int math;
 
  public:
      student();
      student(int number,char name[],string sex,int age,int telphone,int QQ,int china,int english,int math);
      ~student();
      void Set();//添加
      void Delete();//删除
      void Alter();//修改
      void List();//显示
      void Rearch();//查询
};
student::student()
{
    number=0;
    char a[4]=" ";
strcpy(name,a);
sex='M';
age=0;
telphone=0;
QQ=0;
china=0;
english=0;
math=0;
}
student *s[60];
//char name[20];int age,telphone,QQ;string sex;int number;string name;int china;int english;int math;
void student::Set()
{    int i=0;
    int j=0;
    cout<<"输入学号"<<endl;
    cin>>number;
    cout<<"请输入姓名:"<<endl;
    cin>>name;
    cout<<"请输入性别:"<<endl;
    cin>>sex;
    cout<<"请输入年龄:"<<endl;
    cin>>age;
    cout<<"电话号码:"<<endl;
    cin>>telphone;
    cout<<"QQ号码:"<<endl;
    cin>>QQ;
    cout<<"语文成绩"<<endl;
    cin>>china;
    cout<<"英语成绩"<<endl;
    cin>>english;
    cout<<"数学成绩"<<endl;
    cin>>math;
    j++;
s[i]=new student(number,name, sex, age, telphone, QQ, china, english, math);
    i++;
}
void student:: Delete() //(2)删除人员(Delete)
{ int i=60;
    cout<<"请输入您要删除的学生姓名:"<<endl;
    cin>>name;
    for(int h=0;h<60;h++)
    {
    if(strcmp(name,s[h]->name)==0)
    {
    i--;
    s[h]=s[h+1];
    h++;
    }
    else
    {
        cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
    }
    }
}

void student::Alter() //(3)修改数据(Alter)
{   int h;
    cout<<"请输入您要修改的学生的姓名:"<<endl;
    cin>>name;
    for(h=0;h<60;h++)
    {
        if(strcmp(name,s[h]->name)==0)
        {
            string se;
            int nu,ag,qq,ch,en,ma,te;
            cout<<"输入学号"<<endl;
            cin>>nu;
            cout<<"请输入性别:"<<endl;
            cin>>se;
            cout<<"请输入年龄:"<<endl;
            cin>>ag;
            cout<<"电话号码:"<<endl;
            cin>>te;
            cout<<"QQ号码:"<<endl;
            cin>>qq;
            cout<<"语文成绩"<<endl;
            cin>>ch;
            cout<<"英语成绩"<<endl;
            cin>>en;
            cout<<"数学成绩"<<endl;
            cin>>ma;
            s[h]->number=nu;
            s[h]->sex=se;
            s[h]->age=ag;
            s[h]->telphone=te;
            s[h]->QQ=qq;
            s[h]->china=ch;
            s[h]->english=en;
            s[h]->math=ma;
            cout<<"数据修改成功!";
            break;
        }
    }
    if (60 == h-1)
    {
    cout<<"对不起!您要查询的学生不存在!"<<endl;
    }
    //else cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;

}
    void student::List() //(4)显示记录(List)
{
    cout<<"本系统所有通讯录的数据如下:"<<endl;
    if(number==0)
    cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
    for(int k=0;k<60;k++)
    {
    cout<<"学号:"<<s[k]->number<<" ";
    cout<<"姓名:"<<s[k]->name<<" "<< "性别:"<<s[k]->sex<<" "<<"年龄:"<<s[k]->age<<" "<<"电话号码:"<<s[k]->telphone<<" "<<"QQ号码:"
    <<s[k]->QQ<<"语文:"<<s[k]->china<<" "<<"英语:"<<s[k]->english<<" "
    <<"数学:"<<s[k]->number<<" " <<endl;
    }
}

void student::Rearch()
{
    int i=60;
    cout<<"请输入你要查询的学生姓名"<<endl;
    cin>>name;
    for(int j=0;j<i;j++)
    {
        if(strcmp(name,s[j]->name)==0)
        {
        cout<<"您要查询的学生是:"<<s[j]->name<<endl;
        cout<<"性别: "<<s[j]->sex<<" "<<"年龄: "<<s[j]->age<<" "<<"电话号码:"<<s[j]->telphone
        <<" "<<"QQ号码:"<<s[j]->QQ<<endl;
        break;
        }
        if (i == j)
        {
        cout<<"对不起!您要查询的学生不存在!"<<endl;
        }
    }
}

void caozuo(int p)
{
student *t;
    switch(p)
    {
    case 0:t->Set();break;
    case 1:t->Set();break;
    case 2:t->Delete();break;
    case 3:t->Alter();break;
    case 4:t->List();break;
    case 5:t->Rearch();break;
    case 6:exit(0);break;
    }
}
 int main()
{

    char w;
    do
    {
    cout<<"请输入操作代码(/1 增加人员/2 删除人员/3 修改数据/4 显示记录/ 5 按姓名查询/6 退出)"<<endl;
    int a;
    cin>>a;
    caozuo(a);
    cout<<"您想继续进行其他操作吗?(y/n)"<<endl;
    cin>>w;
    }while(w=='y');
    return 0;
}
求帮忙不知道什么错误
搜索更多相关主题的帖子: 信息 english 管理程序 界面设计 private 
2012-05-31 13:57
nongzhaobo
Rank: 3Rank: 3
来 自:广西南宁
等 级:论坛游侠
帖 子:59
专家分:155
注 册:2012-4-8
收藏
得分:8 
哇,那么长??看都头晕了...........
2012-05-31 17:10
丨丨丨
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2012-5-21
收藏
得分:8 
注意一下构造函数的实现
#include<iostream>
 #include<string>
 using namespace std;
 class student
 {
   private:
       int number;
       char name[20];
       string sex;
       int age,telphone,QQ;
       int china;
       int english;
       int math;
   public:
       student(){};//**********这里别忘了大括号
       student(int number,char name[],string sex,int age,int telphone,int QQ,int china,int english,int math);
       ~student(){};//**********这里别忘了大括号
       void Set();//添加
       void Delete();//删除
       void Alter();//修改
       void List();//显示
       void Rearch();//查询
 };
 student::student(int number,char name[],string sex,int age,int telphone,int QQ,int china,int english,int math)//****这里需要传递参数的
 {
    number=0;
    char a[4]=" ";
    strcpy(name,a);
    sex='M';
    age=0;
    telphone=0;
    QQ=0;
    china=0;
    english=0;
    math=0;
 }
 student *s[60];
 //char name[20];int age,telphone,QQ;string sex;int number;string name;int china;int english;int math;
 void student::Set()
 {   int i=0;
     int j=0;
     cout<<"输入学号"<<endl;
     cin>>number;
     cout<<"请输入姓名:"<<endl;
     cin>>name;
     cout<<"请输入性别:"<<endl;
     cin>>sex;
     cout<<"请输入年龄:"<<endl;
     cin>>age;
     cout<<"电话号码:"<<endl;
     cin>>telphone;
     cout<<"QQ号码:"<<endl;
     cin>>QQ;
     cout<<"语文成绩"<<endl;
     cin>>china;
     cout<<"英语成绩"<<endl;
     cin>>english;
     cout<<"数学成绩"<<endl;
     cin>>math;
     j++;
     s[i]=new student(number,name, sex, age, telphone, QQ, china, english, math);
     i++;
 }
 void student:: Delete() //(2)删除人员(Delete)
 {
     int i=60;
     cout<<"请输入您要删除的学生姓名:"<<endl;
     cin>>name;
     for(int h=0;h<60;h++)
     {
        if(strcmp(name,s[h]->name)==0)
        {
            i--;
            s[h]=s[h+1];
            h++;
        }
        else
        {
            cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
        }
     }
 }

void student::Alter() //(3)修改数据(Alter)
 {  
     int h;
     cout<<"请输入您要修改的学生的姓名:"<<endl;
     cin>>name;
     for(h=0;h<60;h++)
     {
         if(strcmp(name,s[h]->name)==0)
         {
             string se;
             int nu,ag,qq,ch,en,ma,te;
             cout<<"输入学号"<<endl;
             cin>>nu;
             cout<<"请输入性别:"<<endl;
             cin>>se;
             cout<<"请输入年龄:"<<endl;
             cin>>ag;
             cout<<"电话号码:"<<endl;
             cin>>te;
             cout<<"QQ号码:"<<endl;
             cin>>qq;
             cout<<"语文成绩"<<endl;
             cin>>ch;
             cout<<"英语成绩"<<endl;
             cin>>en;
             cout<<"数学成绩"<<endl;
             cin>>ma;
             s[h]->number=nu;
             s[h]->sex=se;
             s[h]->age=ag;
             s[h]->telphone=te;
             s[h]->QQ=qq;
             s[h]->china=ch;
             s[h]->english=en;
             s[h]->math=ma;
             cout<<"数据修改成功!";
             break;
         }
     }
     if (60 == h-1)
     {
     cout<<"对不起!您要查询的学生不存在!"<<endl;
     }
     //else cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;

}
 void student::List() //(4)显示记录(List)
 {
    cout<<"本系统所有通讯录的数据如下:"<<endl;
    if(number==0)
    cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
    for(int k=0;k<60;k++)
    {
        cout<<"学号:"<<s[k]->number<<" ";
        cout<<"姓名:"<<s[k]->name<<" "<< "性别:"<<s[k]->sex<<" "<<"年龄:"<<s[k]->age<<" "<<"电话号码:"<<s[k]->telphone<<" "<<"QQ号码:"
            <<s[k]->QQ<<"语文:"<<s[k]->china<<" "<<"英语:"<<s[k]->english<<" "
            <<"数学:"<<s[k]->number<<" " <<endl;
    }
}

void student::Rearch()
 {
     int i=60;
     cout<<"请输入你要查询的学生姓名"<<endl;
     cin>>name;
     for(int j=0;j<i;j++)
     {
         if(strcmp(name,s[j]->name)==0)
         {
         cout<<"您要查询的学生是:"<<s[j]->name<<endl;
         cout<<"性别: "<<s[j]->sex<<" "<<"年龄: "<<s[j]->age<<" "<<"电话号码:"<<s[j]->telphone
         <<" "<<"QQ号码:"<<s[j]->QQ<<endl;
         break;
         }
         if (i == j)
         {
         cout<<"对不起!您要查询的学生不存在!"<<endl;
        }
     }
 }

void caozuo(int p)
 {
     student *t;
     switch(p)
     {
     case 0:t->Set();break;
     case 1:t->Set();break;
     case 2:t->Delete();break;
     case 3:t->Alter();break;
     case 4:t->List();break;
     case 5:t->Rearch();break;
     case 6:exit(0);break;
     }
 }
 int main()
 {

     char w;
     do
     {
     cout<<"请输入操作代码(/1 增加人员/2 删除人员/3 修改数据/4 显示记录/ 5 按姓名查询/6 退出)"<<endl;
     int a;
     cin>>a;
     caozuo(a);
     cout<<"您想继续进行其他操作吗?(y/n)"<<endl;
     cin>>w;
     }while(w=='y');
     return 0;
 }
 
2012-05-31 23:57
lzc8994375
Rank: 1
等 级:新手上路
帖 子:5
专家分:4
注 册:2012-5-21
收藏
得分:0 
回复 3楼 丨丨丨
还是有错啊,当运行的时候会跳出一个“Oxcccccc”内存不能“written”
2012-06-01 09:57
快速回复:学生信息管理程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037303 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved