论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > C语言程序设计教程
Tag:新手,函数,指针,数据类型,对象,Turbo,入门,运算符,数组,结构,二级,,tc,游戏,试题,问答,编译,视频教程

C语言设计学生挡案管理系统

文章类别:C语言程序设计 | 发表日期:2009-6-20 9:34:36

          下面是我研究的用C语言设计的学生档案管理系统,希望对想学习C语言的爱好者有所帮助.......

void XSZL::gototail()
{
    current=tail;
}

void XSZL::print()
{
    int cont=1;
    current=head;
    if(head==null)
        cout<<"\n对不起!学生档案管理库是空的,不能进行打印!!"<<endl<<endl;
    while(current!=null)
    {
        cout<<cont<<"   "<<current<<endl;
        current=current->next;
        cont++;
    }
    gotohead();
}

void XSZL::open()
{
    int i=0;
    int c=0;
    unsigned long d=0;
    FILE *fp;
    XSZLJD *ss;
    char *e;
    e=new char;
    ss=new struct XSZLJD;
    int tt=0;
    char openf[50];
    cout<<"请输入您要打开的文件名:";
    cin>>openf;
    fp=fopen(openf,"rb");
    if((fp=fopen(openf,"rb"))==null)
        cout<<"不能打开文件"<<endl;
    fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(*e!=10&&*e!=13)
    {
    i=0;
    while(1)
    {
    fread(e,sizeof(char),1,fp);
    if(*e==32)
        break;
    if(i==0)
        ss->XH=*e-48;
    else
        ss->XH=ss->XH*10+(*e-48);
    i++;
    }
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
        fread(e,sizeof(char),2,fp);
        if(*e==32)
            break;
        strcpy(ss->XM+i,e);
        i++;
        i++;
    }
    ss->XM[i]=0;
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
    fread(e,sizeof(char),1,fp);
    if(*e==32)
        break;
    if(i==0)
        ss->NL=*e-48;
    else
        ss->NL=ss->NL*10+(*e-48);
    i++;
    }
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
        fread(e,sizeof(char),2,fp);
        if(*e==32)
            break;
        strcpy(ss->XB+i,e);
        i++;
        i++;
    }
    ss->XB[i]=0;
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
        fread(e,sizeof(char),1,fp);
        if(*e==32)
            break;
        strcpy(ss->SS+i,e);
        i++;
    }
    ss->SS[i]=0;
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
        fread(e,sizeof(char),2,fp);
        if(*e==32)
            break;
        strcpy(ss->BJ+i,e);
        i++;
        i++;
    }
    ss->BJ[i]=0;
    i=0;
    while(*e==32)
        fread(e,sizeof(char),1,fp);
    fseek(fp,-1,1);
    while(1)
    {
    fread(e,sizeof(char),1,fp);
    if(*e==13)
        break;
    if(i==0)
        ss->ZHCJ=*e-48;
    else
        ss->ZHCJ=ss->ZHCJ*10+(*e-48);
    i++;
    }
    i=0;
    while(*e==13)
    {
        if(i==6)
            break;
        fread(e,sizeof(char),1,fp);
        fread(e,sizeof(char),1,fp);
        i++;
    }
    fseek(fp,-1,1);
    XSZLJD *newitem;
    newitem=new XSZLJD;
    newitem->prev=null;
    newitem->next=null;
    newitem->dataptr=ss->dataptr;
    newitem->XH=ss->XH;
    strcpy(newitem->XM,ss->XM);//两个数组之间的辅值
    newitem->NL=ss->NL;
    strcpy(newitem->XB,ss->XB);//两个数组之间的辅值
    strcpy(newitem->SS,ss->SS);//两个数组之间的辅值
    strcpy(newitem->BJ,ss->BJ);//两个数组之间的辅值
    newitem->ZHCJ=ss->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;
    tt++;
}
rewind(fp);
print();
    cout<<"导入文件中的数据个数为:"<<tt<<endl;
}

void XSZL::out()
{
    int tt=0;
    current=head;
    char stubase[50];
    cout<<"请输入您要导出文件的名称(名称.txt):";
    cin>>stubase;
    ofstream outclientFile(stubase,ios::out);
    if(!outclientFile)
    {
        cerr<<"文件不能被打开!!"<<endl;
        exit(1);
    }
    while(current!=null)
    {
        outclientFile<<current<<endl;
        current=current->next;
        tt++;
    }
    outclientFile.seekp(0);
    cout<<"导出文件中的数据的个数:"<<tt<<endl;
}

void XSZL::empty()
{
    int o,t;
    XSZLJD *temp,*hold;
    temp=new struct XSZLJD;
    hold=new struct XSZLJD;
    temp=head;
    if(temp==null)
        cout<<"\n对不起!该学生档案库已是空的,不能再进行清空!!"<<endl<<endl;
    while(temp!=null)
    {
        hold=temp->next;
        delete temp;
        temp=hold;
    }
    head=null;
    current=null;
    tail=null;
    count=0;
    cout<<"返回主界面,请输入:(1):";
    cin>>o;

}

#include <iostream.h>
#include <iomanip.h>
#include "XSZL1.H"
void main()
{
    int o,t,e,f;
    o=1;
    while(o==1)
    {
    char x;
    t=1;
    XSZL student;
    cout<<"********************************************************************************"<<endl;
    cout<<setw(46)<<"学生档案管理系统"<<endl;
    cout<<"\n********************************************************************************"<<endl;
    cout<<setw(27)<<"A:插入一个学生数据"<<setw(40)<<"B:删除一个数据项"<<endl;
    cout<<setw(27)<<"C:对数据的组合查询"<<setw(40)<<"D:对数据进行排序"<<endl;
    cout<<setw(27)<<"E:导入一个数据文件"<<setw(40)<<"F:导出全部的数据"<<endl;
    cout<<setw(27)<<"G:打印全部的数据项"<<setw(40)<<"H:清空全部的数据"<<endl;
    cout<<"\n********************************************************************************"<<endl;
    cout<<"设 计 者:***()  ***()"<<endl;
    cout<<"          ***()       ***()    ***()"<<endl;
    cout<<"指导老师:***"<<endl;
    cout<<"院    系:****"<<endl;
    cout<<"设计时间:2003年10月29日"<<endl;
    cout<<"\n********************************************************************************"<<endl;
    cout<<"******请选择要操作的项目(A,B,C,D,E,F,G,H);如果退出输入:(0)******\n";
    cin>>x;
    if(x=='A')
        while(t==1)
        {
            student.insert();
            cout<<"******是否继续进行插入,如果是请输入(1),否则输入(0)******\n";
            cin>>t;
            cout<<"******您是否要对刚插入的全部数据进行其它操作,是输入:1;不是输0******\n";
            cin>>e;
            while(e==1)
            {
                cout<<"******输入2:代表进行查询操作******\n";
                cout<<"******输入3:代表进行删除操作******\n";
                cout<<"******输入4:代表进行打印操作******\n";
                cout<<"******输入5:代表进行排序操作******\n";
                cout<<"******输入6:代表进行清空操作******\n";
                cout<<"******输入7:代表进行导出操作******\n";
                cin>>f;
                if(f==2)
                {
                    student.search();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==3)
                {
                    student.delet();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==4)
                {
                    student.print();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==5)
                {
                    student.sequence();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==6)
                {
                    student.empty();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==7)
                {
                    student.out();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
            }
        }
    else if(x=='B')
        student.delet();
    else if(x=='C')
        student.search();
    else if(x=='D')
        student.sequence();
    else if(x=='E')
    {
        student.open();
        cout<<"******您是否要对刚导入的全部数据进行其它操作,是输入:1;不是输0******\n";
        cin>>e;
        while(e==1)
            {
                cout<<"******输入2:代表进行查询操作******\n";
                cout<<"******输入3:代表进行删除操作******\n";
                cout<<"******输入4:代表进行打印操作******\n";
                cout<<"******输入5:代表进行排序操作******\n";
                cout<<"******输入6:代表进行清空操作******\n";
                cout<<"******输入7:代表进行导出操作******\n";
                cout<<"******输入8:代表进行插入操作******\n";
                cin>>f;
                if(f==2)
                {
                    student.search();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==3)
                {
                    student.delet();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==4)
                {
                    student.print();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==5)
                {
                    student.sequence();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==6)
                {
                    student.empty();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==7)
                {
                    student.out();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
                else if(f==8)
                {
                    student.insert();
                    cout<<"******返回请输入(0),继续操作输入(1)******\n";
                    cin>>e;
                }
            }
    }
    else if(x=='F')
        student.out();
    else if(x=='G')
        student.print();
    else if(x=='H')
        student.empty();
    else if(x=='0')
        break;
    }
}

上一篇:C语言设计变幻线屏保 人气:2389
下一篇:C语言入门必做习题100例(二) 人气:4233
视频教程列表
文章教程搜索
 
C语言程序设计推荐教程
C语言程序设计热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058