| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 530 人关注过本帖
标题:课程设计选题管理系统代码改改吧亲
只看楼主 加入收藏
云淡风清11
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-1-5
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
课程设计选题管理系统代码改改吧亲
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Student
{
    long num;
    char name[20];
    char subject[30];

Student *Next;
    Student *Head;
public:
    int Creat()
    {
        FILE *fp;
        Head = NULL;    //存放链表的起始地址
        Student *p, *pEnd;
        p = new Student; //创建一个动态对象
        if((fp=fopen("Student.txt","r"))==NULL)
        {
            cout << "can not open file!" << endl;
            exit(0);
        }
        fscanf(fp,"%ld%s%s",&p->num,p->name,p->subject); //输入指针p指向的对象的数据成员的值
        pEnd = Head;                          // 存放当前对象的地址   
        while(!feof(fp))
        {                                   // 0 是输入结束的标志
            if(NULL == Head)
                Head = p;                     // 只在第一次执行此语句
            else
                pEnd->Next = p;               // 存放下一个对象的地址
            pEnd = p;
            p = new Student;                  //动态创建下一个对象
            fscanf(fp,"%ld%s%s",&p->num,p->name,p->subject); //输入下一个对象数据成员的值
        }                                   
        pEnd->Next = NULL;                     

    return 0;
    }
    int Newstudent()//************************增加学生信息
    {
        FILE *fp;
        cout << "请输入增加的学生的相关信息: " << endl;
        cout << "学号: " ;
        cin >> num ;
        cout << endl;
        cout << "姓名: " ;
        cin >> name;
        cout << endl;
        cout << "已选课程设计题目: " ;
        cin >> subject;
        cout << endl;
        if((fp=fopen("student.txt","a"))==NULL)
        {
            cout << "can not open file!" << endl;
            exit(0);
        }
        fprintf(fp,"%ld %s %s\n",num,name,subject);
        fclose (fp);
        return 0;
    }
    int Modify()//*****************************修改学生资料
    {
        FILE *fp;
        Student *p;
        char namer[20];

        Creat();
        cout << "请输入要修改的姓名:";
        cin >> namer;
        cout << endl;
        if(Head!=NULL)
        {
            p=Head;
            while(strcmp(namer,p->name))
            {
                p=p->Next;
                if(p==NULL)
                    break;
            }
            if(p!=NULL)
            {
                cout << "你要修改的学生的相关信息如下:" << endl << endl;
                cout << p->num << ' ' << p->name << ' ' << p->subject << endl << endl;
                cout << "请输入修改后的相关信息:" << endl << endl;
                cout << "请输入修改后的学生的学号: ";
                cin >> p->num;
                cout << endl;
                cout << "请输入修改后的姓名: ";
                cin >> p->name;
                cout << endl;
                cout << "请输入修改后的所选题目: ";
                cin >> p->subject;
                cout << endl;
                if((fp=fopen("Student.txt","w"))==NULL)

                {
                    cout << "can not open file!" << endl;
                    exit(0);
                }
                p=Head;
                if(Head!=NULL)
                    do
                    {
                        fprintf(fp,"%ld %s %s\n",p->num,p->name,p->subject);
                        p=p->Next;
                    }
                    while(p!=NULL);
                    fclose (fp);
            }
            
            else
                cout << "没有找到你想要修改的题目的信息" <<endl;
        }        
        else
            cout << "文件中还没有任何题目"<<endl;
        
        return 0;
    }
    int Del()//****************************************删除学生信息
    {
        FILE *fp;
        Student *p,*p1;
        char namer[30];

    Creat();
        cout << "请输入要删除的学生的姓名:";
        cin >> namer;
        cout << endl;
        if(Head!=NULL)
        {
            p=Head;
            while(strcmp(namer,p->name))
            {
                p1=p;
                p=p->Next;
                if(p==NULL)
                    break;
            }
            if(p!=NULL)
            {
                cout << "你要删除的题目的相关信息如下:" << endl;
                cout << "  姓名  : " << p->name<< endl;
                cout << "  学号  : " << p->num << endl;
                cout << "所选题目: " << p->subject << endl;
                system("pause");
                if(p==Head)Head=p->Next;
                else
                    p1->Next=p->Next;
                if((fp=fopen("Student.txt","w"))==NULL)
                {
                    cout << "can not open file!" << endl;
                    exit(0);
                }

                p=Head;
                if(Head!=NULL)
                    do
                    {   
                        fprintf(fp,"%ld %s %s\n",p->num,p->name,p->subject);
                        p=p->Next;
                    }
                    while(p!=NULL);
                    fclose (fp);
                    cout << "该学生的所有信息已被删除!" << endl;
            }
            
            else
                cout << "没有找到你想要删除的学生的信息" <<endl;
        }        
        else
            cout << "文件中还没有任何学生的信息"<<endl;
        return 0;
    }
};
class Subject//***************************************************************************************
{
    int serial_number;//序号
    char subject[30]; //题目
    int peoples;//限定人数
    int people;//已选人数

    char description[100];//所选课程的描述   
    Subject *next;
    Subject *head;
public:
    int Chosesubject();
    int creat();
    int newsubject();
    int modify();
    int del();
    int demand();
};
int Subject::creat()
{
    FILE *fp;
    head = NULL;    //存放链表的起始地址
    Subject *p, *pEnd;
    p = new Subject; //创建一个动态对象
    if((fp=fopen("Subject.txt","r"))==NULL)
    {
        cout << "can not open file!" << endl;
        exit(0);
    }
    fscanf(fp,"%d%s%d%s%d",&p->serial_number,p->subject,&p->peoples,p->description,&p->people); //输入指针p指向的对象的数据成员的值
    pEnd = head;                          // 存放当前对象的地址   
    while(!feof(fp))
    {                                   // 0 是输入结束的标志
        if(NULL == head)
            head = p;                     // 只在第一次执行此语句

        else
            pEnd->next = p;               // 存放下一个对象的地址
        pEnd = p;
        p = new Subject;                  //动态创建下一个对象
        fscanf(fp,"%d%s%d%s%d",&p->serial_number,p->subject,&p->peoples,p->description,&p->people); //输入下一个对象数据成员的值
    }                                   
    pEnd->next = NULL;                        
    return 0;
}
int Subject::newsubject()//************************************增加新的题目
{
    FILE *fp;
    cout << "请输入要增加的题目的序号:";
    cin >> serial_number;
    cout << endl;
    cout << "请输入要增加的题目:";
    cin >> subject;
    cout << endl;
    cout << "请输入要增加的题目的人数限定:";
    cin >> peoples;
    cout << endl;
    cout << "请输入要增加的题目的描述::";
    cin >> description;
    cout << endl;
    cout << "请输入要增加的题目的已选人数:";
    cin >> people;

    cout << endl;
    if((fp=fopen("Subject.txt","a"))==NULL)
    {
        cout << "can not open file!" << endl;
        exit(0);
    }
    fprintf(fp,"%d %s %d %s %d\n",serial_number,subject,peoples,description,people);
    return 0;
}
int Subject::modify()//*****************************修改
{
    FILE *fp;
    Subject *p;
    char sub[30];
    creat();
    cout << "请输入要修改的题目:";
    cin >> sub;
    cout << endl;
    if(head!=NULL)
    {
        p=head;
        while(strcmp(sub,p->subject))
        {
            p=p->next;
            if(p==NULL)
                break;
        }
        if(p!=NULL)

    {
            cout << "你要修改的题目的相关信息如下:" << endl;
            cout << p->serial_number << ' ' << p->subject << ' ' << p->people << ' ' << p->description << endl;
            cout << "请输入修改后的相关信息:" << endl;
            cout << "请输入修改后的题目的序号:";
            cin >> p->serial_number;
            cout << endl;
            cout << "请输入修改后的题目:";
            cin >> p->subject;
            cout << endl;
            cout << "请输入修改后的题目的人数限定:";
            cin >> p->peoples;
            cout << endl;
            cout << "请输入修改后的题目的描述::";
            cin >> p->description;
            cout << endl;
            cout << "请输入修改后的题目的已选人数:";
            cin >> p->people;
            cout << endl;
            if((fp=fopen("Subject.txt","w"))==NULL)
            {
                cout << "can not open file!" << endl;
                exit(0);
            }
            p=head;
            if(head!=NULL)
                do
                {

                    fprintf(fp,"%d %s %d %s %d\n",p->serial_number,p->subject,p->peoples,p->description,p->people);
                    p=p->next;
                }
                while(p!=NULL);
                fclose (fp);
        }
        
        else
            cout << "没有找到你想要修改的题目的信息" <<endl;
    }        
    else
        cout << "文件中还没有任何题目"<<endl;
   
    return 0;
}
int Subject::del()//****************************************删除
{
    FILE *fp;
    Subject *p,*p1;
    char sub[30];
    creat();
    cout << "请输入要删除的题目:";
    cin >> sub;
    cout << endl;
    if(head!=NULL)
    {
        p=head;

        while(strcmp(sub,p->subject))
        {
            p1=p;
            p=p->next;
            if(p==NULL)
                break;
        }
        if(p!=NULL)
        {
            cout << "你要删除的题目的相关信息如下:" << endl;
            cout << "  序号  : " << p->serial_number << endl;
            cout << "  题目  : " << p->subject << endl;
            cout << "限定人数: " << p->peoples << endl;
            cout << "题目描述: " << p->description << endl;
            cout << "已选人数: " << p->people << endl;
            system("pause");
            if(p==head)head=p->next;
            else
                p1->next=p->next;
            if((fp=fopen("Subject.txt","w"))==NULL)
            {
                cout << "can not open file!" << endl;
                exit(0);
            }
            p=head;
            if(head!=NULL)
                do
                {
                    fprintf(fp,"%d %s %d %s %d\n",p->serial_number,p->subject,p->peoples,p->description,p->people);
                    p=p->next;
                }
                while(p!=NULL);
                fclose (fp);
                cout << "该题目的所有信息已被删除!" << endl;
        }
        else
            cout << "没有找到你想要删除的题目的信息" <<endl;
    }        
    else
        cout << "文件中还没有任何题目"<<endl;
    return 0;
}
int Subject::demand()//***************************************查询课程设计题目
{
    Subject *p,*p1;
    char sub[30];
    creat();
    cout << "所有题目列表如下" << endl;
    p=head;
    while(p != NULL)                     
    {                                 
        cout << "序号: " << p->serial_number << "      题目  : " << p->subject << endl;   
        cout << endl;
        p = p->next;                     

    }
    cout << "                 请输入你想要查看的题目: " ;
    cin >> sub;
    cout << endl;
    if(head!=NULL)
    {
        p=head;
        while(strcmp(sub,p->subject))
        {
            p1=p;
            p=p->next;
            if(p==NULL)
                break;
        }
        if(p!=NULL)
            cout << "关于该题目有如下描述:"<< endl << p->description << endl;
        else
            cout << "没有找到你想要修改的题目的信息" <<endl;
    }        
    else
        cout << "文件中还没有任何题目"<<endl;
    return 0;
}
int Subject::Chosesubject()
{
    FILE *fp;
    Subject *p,*p1;
    char sub[30];

    creat();
    cout << "请输入你要选择的题目: ";
    cin >> sub;
    cout << endl;
    if(head!=NULL)
    {
        p=head;
        while(strcmp(sub,p->subject))
        {
            p1=p;
            p=p->next;
            if(p==NULL)
                break;
        }
        if(p!=NULL)
        {
            if(p->people>=p->peoples)
            {
                cout << "人数超限!你不能再选择此题目!" << endl;
                exit(0);
            }
            Student a;
            a.Newstudent();            
            p->people++;
            if((fp=fopen("Subject.txt","w"))==NULL)
            {
                cout << "can not open file!" << endl;
                exit(0);
            }

            p=head;
            if(head!=NULL)
                do
                {
                    fprintf(fp,"%d %s %d %s %d\n",p->serial_number,p->subject,p->peoples,p->description,p->people);
                    p=p->next;
                }
                while(p!=NULL);
            cout << "****选题成功!***" << endl;
                fclose (fp);
        }
        else
            cout << "没有找到你想要修改的题目的信息" <<endl;
    }        
    else
        cout << "文件中还没有任何题目"<<endl;
    return 0;
}
int  main()
{
    system("color 1d");
    Subject a;
    Student b;
   
char  choice;

 cout<<"\n\n\t        ★欢迎使用课程设计选课系统★\n\n";

cout<<"\t1.★★★★添加新的科目★★★★★★★★★\n";
 cout<<"\t2.********删除所选内容******************\n";
 cout<<"\t3.★★★★修改课程设计信息★★★★★★★\n";
 cout<<"\t4.********添加新的学生的相关信息********\n";
 cout<<"\t5.★★★★删除学生记录★★★★★★★★★\n\n\n";
 cout<<"\t6.********修改学生信息******************\n";
 cout<<"\t7.★★★★查询课程设计内容★★★★★★★\n";
 cout<<"\t8.********进行课程设计选课**************\n";
 cout<<"\t0.★★★★退出系统★★★★★★★★★★★\n\n\n";
cout<<"\t        ★***制作人: ***★\n\n\n";
 cout<<"请输入您的选择:";
 cin>>choice;
 if(choice=='0')
     exit(0);
else
if(choice=='1')
{ a.newsubject();
system("pause");
main();

}
   else  if(choice=='2')
   {a.del();
system("pause");
   main();}
else if(choice=='3')   
{a.modify();
system("pause");
main();}

else if(choice=='4')   
{b.Newstudent();
system("pause");
main();}
else
 if(choice=='5')   
 {b.Del();
system("pause");
 main();}
else if(choice=='6')   
{b.Modify();
system("pause");
main();}
else if(choice=='7')   
{a.demand();
system("pause");
main();}

else if(choice=='8')   
{a.Chosesubject();
system("pause");
main();}

else
 cout<<"输入错误,请重新输入您的选择:";
system("pause");
main();
}
搜索更多相关主题的帖子: public 管理系统 include file 动态 
2013-01-05 17:15
smile康师傅
Rank: 2
等 级:论坛游民
帖 子:34
专家分:53
注 册:2012-6-10
收藏
得分:10 
都没说明是什么个问题的,这叫人怎么改啊???建议你把遇到的具体问题说明下。。。方便大家帮你解决啊!!!
2013-01-05 23:54
云淡风清11
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-1-5
收藏
得分:0 
能运行但运行结果有问题,输入2,3,7,8这几个模块时,运行结果不对,帮忙改改哈亲,三克油
2013-01-06 09:42
不玩虚的
Rank: 9Rank: 9Rank: 9
来 自:四川
等 级:贵宾
威 望:10
帖 子:331
专家分:1301
注 册:2012-12-9
收藏
得分:10 
有的开发的意思,能说说哪几个模板的思想不,别人好帮你改,或者重写也方便啦。

同学习......同进步....你帮我......我帮你.....上善若水.....
2013-01-06 12:55
HEIDONG12345
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-1-8
收藏
得分:0 
这个程序的查询功能执行不了,修改了吗
2020-01-08 15:37
快速回复:课程设计选题管理系统代码改改吧亲
数据加载中...
 
   



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

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