回 帖 发 新 帖 刷新版面

主题:学生挡案管理系统原代码

#define  null 0
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
#include "xszl1.h"


XSZL::XSZL()
{
    count=0;
    head=null;
    tail=null;
    current=null;
}

XSZL::insert()//插入一个学生数据
{
    if(head==null)
        cout<<"\n您目前要进行操作的学生数据库是个空的数据库!!"<<endl<<endl;
    int e;
    XSZLJD *item;
    item=new struct XSZLJD;
    cout<<"\n***请输入学生数据项的各个数据:(学号,姓名,年龄,性别,宿舍,班级,综合成绩)***"<<endl;
    cout<<"\n请输入学号:";
    cin>>item->XH;
    cout<<"\n请输入姓名:";
    cin>>item->XM;
    cout<<"\n请输入年龄:";
    cin>>item->NL;
    cout<<"\n请输入性别:";
    cin>>item->XB;
    cout<<"\n请输入宿舍:";
    cin>>item->SS;
    cout<<"\n请输入班级:";
    cin>>item->BJ;
    cout<<"\n请输入综合成绩:";
    cin>>item->ZHCJ;
    struct XSZLJD *newitem;
    newitem=new struct XSZLJD;
    newitem->prev=null;
    newitem->next=null;
    newitem->dataptr=item->dataptr;
    newitem->XH=item->XH;
    strcpy(newitem->XM,item->XM);//两个数组之间的辅值
    newitem->NL=item->NL;
    strcpy(newitem->XB,item->XB);//两个数组之间的辅值
    strcpy(newitem->SS,item->SS);//两个数组之间的辅值
    strcpy(newitem->BJ,item->BJ);//两个数组之间的辅值
    newitem->ZHCJ=item->ZHCJ;
    if(head==null)
    {
        head=newitem;
        tail=newitem;
        current=newitem;
    }
    else
    {
        if(current==tail)
        {
            newitem->prev=current;
            newitem->next=null;
            current->next=newitem;
            tail=newitem;
            current=newitem;
        }
        else
        {
            newitem->prev=current;
            newitem->next=current->next;
            current->next->prev=newitem;
            current->next=newitem;
        }
    }
++count;
print();
}

XSZL::delet()//删除一个学生数据
{
    if(head==null)
        cout<<"\n该学生数据库已是空的!!删除无效!!"<<endl<<endl;
    else
    {
    XSZLJD *item;
    item=new struct XSZLJD;
    cout<<"请输入要删除学生数据项的学号:";
    cin>>item->XH;
    XSZLJD *temp;
    temp=new struct XSZLJD;
    temp=head;
    while(temp!=null)
    {
        if(temp->XH==item->XH)
        {
            if(temp==current)
                current=temp->next;
            if(temp->prev==null)
            {
                head=temp->next;
                if(head!=null)
                    head->prev=null;
                if(temp->next==null)
                    tail=null;
            }
            else
            {
                temp->prev->next=temp->next;
                if(temp->next==null)
                    tail=temp->prev;
                else
                    temp->next->prev=temp->prev;
            }
            delete temp;
            --count;
            return 0;
        }
        temp=temp->next;
    }
    return 1;
    }
}

void XSZL::sequence()//冒泡法
{
    int a,b;
    if(head==null)
        cout<<"空的学生数据库!!排序无效!!"<<endl<<endl;
    else
    {
    cout<<"a=0,按学号排序;\na=1,按年龄排序;\na=2,按综合成绩排序;\nb=0,按升序排序;\nb=1,按降序排序;\n";
    cout<<"请输入a=";
    cin>>a;
    cout<<"\n请输入b=";
    cin>>b;
    if(a==0&&b==0)
    {
    XSZLJD *temp,*ss;
    for(unsigned long i=0;i<count;i++)
    {
        temp=head;
        while(temp->next!=null)
        {
            if(temp->XH>temp->next->XH)
            {
                ss=temp->next;
                if(temp==current)
                    current=temp->next;
                if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                    temp->prev=ss;
                    ss->next=temp;
                    temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
    else if(a==0&&b==1)
    {
        XSZLJD *temp,*ss;
        temp=new struct XSZLJD;
        ss=new struct XSZLJD;
        for(unsigned long i=0;i<count;i++)
        {
            temp=head;
            while(temp->next!=null)
            {
                if(temp->XH<temp->next->XH)
                {
                    ss=temp->next;
                    if(temp==current)
                        current=temp->next;
                    if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                    temp->prev=ss;
                    ss->next=temp;
                    temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
    else if(a==1&&b==0)
    {
        XSZLJD *temp,*ss;
        temp=new struct XSZLJD;
        ss=new struct XSZLJD;
        for(unsigned long i=0;i<count;i++)
        {
            temp=head;
            while(temp->next!=null)
            {
                if(temp->NL>temp->next->NL)
                {
                    ss=temp->next;
                    if(temp==current)
                        current=temp->next;
                    if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                    temp->prev=ss;
                    ss->next=temp;
                    temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
    else if(a==1&&b==1)
    {
        XSZLJD *temp,*ss;
        temp=new struct XSZLJD;
        ss=new struct XSZLJD;
        for(unsigned long i=0;i<count;i++)
        {
            temp=head;
            while(temp->next!=null)
            {
                if(temp->NL<temp->next->NL)
                {
                    ss=temp->next;
                    if(temp==current)
                        current=temp->next;
                    if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                        temp->prev=ss;
                        ss->next=temp;
                        temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
    else if(a==2&&b==0)
    {
        XSZLJD *temp,*ss;
        temp=new struct XSZLJD;
        ss=new struct XSZLJD;
        for(unsigned long i=0;i<count;i++)
        {
            temp=head;
            while(temp->next!=null)
            {
                if(temp->ZHCJ>temp->next->ZHCJ)
                {
                    ss=temp->next;
                    if(temp==current)
                        current=temp->next;
                    if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                        temp->prev=ss;
                        ss->next=temp;
                        temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
    else if(a==2&&b==1)
    {
        XSZLJD *temp,*ss;
        temp=new struct XSZLJD;
        ss=new struct XSZLJD;
        for(unsigned long i=0;i<count;i++)
        {
            temp=head;
            while(temp->next!=null)
            {
                if(temp->ZHCJ<temp->next->ZHCJ)
                {
                    ss=temp->next;
                    if(temp==current)
                        current=temp->next;
                    if(temp->prev==null)
                    {
                        head=temp->next;
                        if(head!=null)
                            head->prev=null;
                        if(temp->next==null)
                            tail=null;
                    }
                    else
                    {
                        temp->prev->next=temp->next;
                        if(temp->next==null)
                            tail=temp->prev;
                        else
                            temp->next->prev=temp->prev;
                    }
                    temp->next=ss->next;
                    if(temp->next!=null)
                    {
                        temp->prev=ss;
                        ss->next=temp;
                        temp->next->prev=temp;
                    }
                    else
                    {
                        ss->next=temp;
                    }
                }
                else
                    temp=temp->next;
            }
            tail=temp;
        }
    }
print();
}
}
续下学生档案管理系统原代码1………………

回复列表 (共4个回复)

沙发

楼主,你好,我现在正在学TC,我现在急需一800行的用C语言编写的能在VC++下运行的管理系统,看到大家发的都是VC语言写的 ,心里真是.......................
哎,楼主大虾,帮帮小弟吧,江湖救急啊   555555

板凳

我是一名学生,我很喜欢以语言,也非常谢谢你的c语言的程序,出次交谈我想我们会成为朋友的,你说哪.祝愿朋友你天天可乐,同时也希望我们能经常联系[em20]

3 楼

请问#include "xszl1.h"中头文件有什么内容啊,不能运行这个程序啊,缺少 "xszl1.h"

4 楼

楼主,请问那个#include "xszl1.h"出错啊,请楼主帮忙啊!小弟多谢了!!!!!

我来回复

您尚未登录,请登录后再回复。点此登录或注册