| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 710 人关注过本帖, 1 人收藏
标题:学生管理系统、职工管理系统类似xx管理系统题目的模板,有需要的拿去修改
只看楼主 加入收藏
oszc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:111
专家分:154
注 册:2011-4-15
结帖率:100%
收藏(1)
 问题点数:0 回复次数:6 
学生管理系统、职工管理系统类似xx管理系统题目的模板,有需要的拿去修改
程序代码:
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>

struct information{    
    int num;                    //工号
    char name[30];                    
    char birth[20];
    char gender[10];        //性别
    char education[20]; //学历
    char position[30];   //职位
    double wage;            //工资
    char address[200];
    char phone[15];
    struct information *next;
};
typedef struct information infor;
typedef infor *inforPtr;

void menu(void);            
void add (inforPtr *sPtr,int value);
int exist(inforPtr *sPtr, int value);
void display(inforPtr newList);
void query (inforPtr *sPtr, int (*compare)(inforPtr original, inforPtr creat));
int queryByWage (inforPtr original , inforPtr creat);
void save (inforPtr *sPtr);
void load ( inforPtr * sPtr);
void del (inforPtr *sPtr,int value);

int main (void)
{
    inforPtr startList=NULL;
    int select;
    int num;
    int delNum;

    printf ("**************************欢迎使用职工信息管理系统*****************************\n");
                      
    load(&startList);   //读取文件数据,传入链表以便传从load函数递链表至主函数
    display(startList); 

    printf("\n\n\n");

    menu();
    scanf("%d", &select);

    while(select != 9)
    {
        switch (select){
        case 1:
            printf("输入工号:\n?");
            scanf("%d", &num);
            if( exist(&startList ,num) )
            {
                printf("记录已经存在,不能添加\n\n");
                break;
            }
            else
                add (&startList ,num);
            break;
        case 2:
            display(startList);
            break;
        case 3:
            query(&startList,queryByWage);
            break;
        case 4:
        //    save(&startList);
            break;
        case 5:
        //    load(&startList);
            break;
        case 6:
            printf("输入要删除员工工号:\n?");
            scanf("%d", &delNum);
            if( !exist(&startList ,delNum) )
            {
                printf("记录不存在,无法删除!\n\n");
                break;
            }
            else
                del(&startList,delNum);
            break;

        }
        menu();
        scanf("%d", &select);
        }
    return 0;
}

/****菜单*****/
void menu (void)
{
    puts("1. 增加新纪录.");
    puts("2. 按工号显示记录");
    puts("3. 按工资排序");
//    puts("4. 保存");
//    puts("5. 读取");
    puts("6. 删除");
    puts("9. 退出");
    printf("? ");
}

/*判断是否已经存在工号*/
int exist (inforPtr *sPtr , int value)  /*判断工号是否已经存在*/
{
    inforPtr current;
    current = *sPtr;
    while(current != NULL )
    {
        if (value == current->num)
        return 1;
        current=current->next;
    }
        return 0;
}  

void add (inforPtr *sPtr,int value)  /*使用链表 添加记录*/
{
    inforPtr current;
    inforPtr prev;
    inforPtr newList;
    int c;
    /* char str[450]={0};  */

    if ( (newList = (struct information *) malloc (sizeof (struct information))) != NULL)
    {
        current = *sPtr;
        prev = NULL;

        newList->num = value;
        newList ->next = NULL;

        while( (c=getchar())!='\n' && c !=NULL);     //fflush(stdin)

/*      printf("%-10s%-10s%-10s%-15s%-10s%-10s%-20s%s\n","姓名","出生年月","性别","教育程度","职位","工资","住址","电话");

        gets(str);
        sscanf(str,"%[^0-9]%s%s%s%s%lf%s%s", newList->name, newList->birth, newList->gender, newList->education,
            newList->position, &newList->wage, newList->address, newList->phone);                                     */
        printf("姓名:\n");
        scanf("%s",newList->name);
        printf("\n出生年月:\n");
        scanf("%s",newList->birth);
        printf("\n性别:\n");
        scanf("%s",newList->gender);
        printf("\n教育程度:\n");
        scanf("%s",newList->education);
        printf("\n职位:\n");
        scanf("%s",newList->position);
        printf("\n工资:\n");
        scanf("%lf",&newList->wage);
        printf("\n住址:\n");
        scanf("%s",newList->address);
        printf("\n电话:\n");
        scanf("%s",newList->phone);
        
        while ( current != NULL && value > current ->num)
        {
            prev = current;
            current = current ->next;
        }

        if(prev == NULL)
        {
            newList->next=*sPtr;
            *sPtr = newList;
        }
        else
        {
            newList->next=current;
            prev->next = newList;
        }

        
    }
    else
        printf("内存已满,无法添加\n");

    save(sPtr);
    }

/*显示链表中数据*/
void display( inforPtr newList)
{
    fflush(stdout);

    printf("\n\n************************************************************************************************************************\n\n");
    printf("%-5s%-13s%-12s%-5s%-15s%-10s%-10s%-40s%s\n","工号","姓名","出生年月","性别","教育程度","职位","工资","住址","电话");

    while (newList != NULL)
    {
        printf("%-5.3d%-13s%-12s%-5s%-15s%-10s%-10.2lf%-40s%s\n",newList->num, newList->name, newList->birth, newList->gender, newList->education,
            newList->position, newList->wage, newList->address, newList->phone);
        newList = newList->next;
    }
    printf("\n*************************************************************************************************************************\n\n");
}

void query (inforPtr *sPtr, int (*compare)(inforPtr original, inforPtr creat))
{
    inforPtr SPtr;  //equal to *sPtr
    inforPtr newPtr;  //newList
    inforPtr currentPtr;
    inforPtr prevPtr;
    inforPtr headPtr;

    SPtr =*sPtr;
    newPtr = NULL;
    currentPtr = NULL;
    prevPtr = NULL;
    headPtr = NULL;
    while (SPtr != NULL)
    {
        if( ( newPtr = ( struct information *) malloc ( sizeof (struct information) ) ) != NULL)
        {
            prevPtr = NULL;
            currentPtr = headPtr;

            newPtr->next = NULL;

            /*move*/
            while( currentPtr != NULL && (*compare)(SPtr , currentPtr))
            {
                prevPtr = currentPtr;
                currentPtr = currentPtr ->next ;
            }
            if ( prevPtr == NULL)
            {
                newPtr->next = headPtr;
                headPtr = newPtr;
            }
            else
            {
                prevPtr->next = newPtr;
                newPtr ->next = currentPtr;
            }
            strcpy (newPtr->address , SPtr->address);
            strcpy (newPtr->birth ,SPtr ->birth );
            strcpy (newPtr->education, SPtr->education);
            strcpy(newPtr->gender , SPtr->gender);
            strcpy(newPtr->name , SPtr ->name);
            newPtr ->num = SPtr->num;
            strcpy(newPtr->phone, SPtr ->phone);
            strcpy (newPtr ->position ,SPtr ->position);
            newPtr->wage = SPtr->wage;

            SPtr=SPtr->next;
        }
        else 
            printf("OUT OF MEMORY \n");                            
    }
display(headPtr);
}


/*按照工资排序*/
int queryByWage (inforPtr original , inforPtr creat)
{
    return original->wage < creat ->wage;
}

/*保存到文件*/
void save (inforPtr *sPtr)
{
    FILE *fPtr;
    inforPtr SPtr;
    SPtr=*sPtr;

    if ( (fPtr=fopen("data.dat","wb++")) !=NULL)
    {
        while (SPtr !=NULL)
        {
        fwrite(SPtr ,sizeof( struct information) , 1 ,fPtr);
        SPtr=SPtr->next;
        }
    
    }
    else
    {
        printf("File can not open!\n\n");
        exit(0);
    }

    fclose(fPtr);
    printf("\n*****自动保存成功!*****\n\n");

}

void load ( inforPtr *sPtr)
{
    FILE *fPtr;
    infor newList ;
    inforPtr currentPtr = NULL;
    inforPtr headPtr = NULL;
    inforPtr newPtr = NULL;
    inforPtr prevPtr = NULL;
    int verify=-100;
    struct _stat verifyFile;

    if ( (fPtr=fopen("data.dat","rb++")) == NULL)
    {
        if ( (fPtr=fopen("data.dat","wb++")) == NULL)
            printf("File can not open");
        else 
            printf (    "\n欢迎首次使用,本系统所有数据将自动保存!\n"     );                    
    }
    else 
    {   
        stat("data.dat",&verifyFile);

        if (verifyFile.st_size != 0)
        {


        headPtr=NULL;
        newPtr= NULL;
        currentPtr = NULL;

        while(!feof(fPtr))
        {
            fread(&newList, sizeof(struct information),1,fPtr);

    /*    printf("%-5.3d%-10s%-10s%-10s%-15s%-10s%-10.2lf%-20s%s\n",newList.num, newList.name, newList.birth, newList.gender, newList.education,
        newList.position, newList.wage, newList.address, newList.phone);
        */
            if(verify != newList.num)
            {
                if( ( newPtr = ( struct information *) malloc ( sizeof (struct information) ) ) != NULL)
                {
                    prevPtr = NULL;
                    currentPtr = headPtr;
                    newPtr->next = NULL;
                
                        while( currentPtr != NULL && newList.num>currentPtr->num)
                        {
                            prevPtr = currentPtr;
                            currentPtr = currentPtr ->next ;
                        }
                        if ( prevPtr == NULL)
                        {
                            newPtr->next = headPtr;
                            headPtr = newPtr;
                        }
                        else
                        {
                            prevPtr->next = newPtr;
                            newPtr ->next = currentPtr;
                        }
                    
                                strcpy (newPtr->address , newList.address);
                                strcpy (newPtr->birth ,newList.birth );
                                strcpy (newPtr->education, newList.education);
                                strcpy(newPtr->gender , newList.gender);
                                strcpy(newPtr->name , newList.name);
                                newPtr ->num = newList.num;
                                strcpy(newPtr->phone, newList.phone);
                                strcpy (newPtr ->position ,newList.position);
                                newPtr->wage = newList.wage;
                                verify = newList.num;
                }  /* END IF ALLOC */
            }   /* END IF VERIFY */
        }  /*END WHILE */

        *sPtr=headPtr;  /*把文件头传递到main*/
        fclose(fPtr); 
        printf("\n********读取 \"数据库\" 成功!********\n\n");
        }//end stat if
    } /*end else*/
}
    
void del (inforPtr *sPtr,int value)
{
    inforPtr currentPtr;
    inforPtr prevPtr;

    currentPtr= *sPtr;
    prevPtr =NULL;

    while (currentPtr != NULL &&  value != currentPtr ->num)
    {
        prevPtr = currentPtr;
        currentPtr = currentPtr ->next;
    }
    if (prevPtr == NULL)
    {
        *sPtr=currentPtr->next;
    }
    else
    {
        prevPtr->next = currentPtr->next;
    }
    save(sPtr);
}

我是按照下面帖子要求编的,其余系统都很类似,修改输出名称或者删除一些不需要的变量即可。
https://bbs.bccn.net/thread-342476-1-2.html

[ 本帖最后由 oszc 于 2011-6-13 22:17 编辑 ]
搜索更多相关主题的帖子: 管理系统 
2011-06-13 18:05
cosdos
Rank: 9Rank: 9Rank: 9
来 自:ShangHai
等 级:蜘蛛侠
威 望:6
帖 子:2109
专家分:1385
注 册:2007-6-19
收藏
得分:0 
顶一下

—>〉Sun〈<—
2011-06-13 18:11
eptiantian
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-10-28
收藏
得分:0 
楼主好人
2013-10-28 14:42
淡蓝殇感
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-12-17
收藏
得分:0 
感激不尽
2013-12-17 20:26
淡蓝殇感
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-12-17
收藏
得分:0 
大神,帮忙修给下,这个怎么运行不了
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>

struct information{   
    int num;                    //工号
    char name[30];                    
    char birth[20];
    char gender[10];        //性别
    char position[30];   //职位
    double wage;            //车号
    char address[200];
    char phone[15];
    struct information *next;
};
typedef struct information infor;
typedef infor *inforPtr;

void menu(void);            
void add (inforPtr *sPtr,int value);
int exist(inforPtr *sPtr, int value);
void display(inforPtr newList);
void query (inforPtr *sPtr, int (*compare)(inforPtr original, inforPtr creat));
int queryByWage (inforPtr original , inforPtr creat);
void save (inforPtr *sPtr);
void load ( inforPtr * sPtr);
void del (inforPtr *sPtr,int value);

int main (void)
{
    inforPtr startList=NULL;
    int select;
    int num;
    int delNum;

    printf ("**************************欢迎使用校车管理信息系统*****************************\n");
                     
    load(&startList);   //读取文件数据,传入链表以便传从load函数递链表至主函数
    display(startList);

    printf("\n\n\n");

    menu();
    scanf("%d", &select);

    while(select != 9)
    {
        switch (select){
        case 1:
            printf("输入工号:\n?");
            scanf("%d", &num);
            if( exist(&startList ,num) )
            {
                printf("记录已经存在,不能添加\n\n");
                break;
            }
            else
                add (&startList ,num);
            break;
        case 2:
            display(startList);
            break;
        case 3:
            query(&startList,queryByWage);
            break;
        case 4:
        //    save(&startList);
            break;
        case 5:
        //    load(&startList);
            break;
        case 6:
            printf("输入要删除员工工号:\n?");
            scanf("%d", &delNum);
            if( !exist(&startList ,delNum) )
            {
                printf("记录不存在,无法删除!\n\n");
                break;
            }
            else
                del(&startList,delNum);
            break;

        }
        menu();
        scanf("%d", &select);
        }
    return 0;
}

/****菜单*****/
void menu (void)
{
    puts("1. 增加新纪录.");
    puts("2. 按工号显示记录");
    puts("3. 按车号排序");
//    puts("4. 保存");
//    puts("5. 读取");
    puts("6. 删除");
    puts("9. 退出");
    printf("? ");
}

/*判断是否已经存在工号*/
int exist (inforPtr *sPtr , int value)  /*判断工号是否已经存在*/
{
    inforPtr current;
    current = *sPtr;
    while(current != NULL )
    {
        if (value == current->num)
        return 1;
        current=current->next;
    }
        return 0;
}  

void add (inforPtr *sPtr,int value)  /*使用链表 添加记录*/
{
    inforPtr current;
    inforPtr prev;
    inforPtr newList;
    int c;
    /* char str[450]={0};  */

    if ( (newList = (struct information *) malloc (sizeof (struct information))) != NULL)
    {
        current = *sPtr;
        prev = NULL;

        newList->num = value;
        newList ->next = NULL;

        while( (c=getchar())!='\n' && c !=NULL);     //fflush(stdin)

/*      printf("%-10s%-10s%-10s%-15s%-10s%-10s%-20s%s\n","姓名","出生年月","性别","职位","车号","住址","电话");

        gets(str);
        sscanf(str,"%[^0-9]%s%s%s%s%lf%s%s", newList->name, newList->birth, newList->gender, newList->education,
            newList->position, &newList->wage, newList->address, newList->phone);                                     */
        printf("姓名:\n");
        scanf("%s",newList->name);
        printf("\n出生年月:\n");
        scanf("%s",newList->birth);
        printf("\n性别:\n");
        scanf("%s",newList->gender);
        printf("\n职位:\n");
        scanf("%s",newList->position);
        printf("\n车号:\n");
        scanf("%lf",&newList->wage);
        printf("\n住址:\n");
        scanf("%s",newList->address);
        printf("\n电话:\n");
        scanf("%s",newList->phone);
        
        while ( current != NULL && value > current ->num)
        {
            prev = current;
            current = current ->next;
        }

        if(prev == NULL)
        {
            newList->next=*sPtr;
            *sPtr = newList;
        }
        else
        {
            newList->next=current;
            prev->next = newList;
        }

        
    }
    else
        printf("内存已满,无法添加\n");

    save(sPtr);
    }

/*显示链表中数据*/
void display( inforPtr newList)
{
    fflush(stdout);

    printf("\n\n************************************************************************************************************************\n\n");
    printf("%-5s%-13s%-12s%-5s%-15s%-10s%-10s%-40s%s\n","工号","姓名","出生年月","性别","职位","车号","住址","电话");

    while (newList != NULL)
    {
        printf("%-5.3d%-13s%-12s%-5s%-15s%-10s%-10.2lf%-40s%s\n",newList->num, newList->name, newList->birth, newList->gender, newList->education,
            newList->position, newList->wage, newList->address, newList->phone);
        newList = newList->next;
    }
    printf("\n*************************************************************************************************************************\n\n");
}

void query (inforPtr *sPtr, int (*compare)(inforPtr original, inforPtr creat))
{
    inforPtr SPtr;  //equal to *sPtr
    inforPtr newPtr;  //newList
    inforPtr currentPtr;
    inforPtr prevPtr;
    inforPtr headPtr;

    SPtr =*sPtr;
    newPtr = NULL;
    currentPtr = NULL;
    prevPtr = NULL;
    headPtr = NULL;
    while (SPtr != NULL)
    {
        if( ( newPtr = ( struct information *) malloc ( sizeof (struct information) ) ) != NULL)
        {
            prevPtr = NULL;
            currentPtr = headPtr;

            newPtr->next = NULL;

            /*move*/
            while( currentPtr != NULL && (*compare)(SPtr , currentPtr))
            {
                prevPtr = currentPtr;
                currentPtr = currentPtr ->next ;
            }
            if ( prevPtr == NULL)
            {
                newPtr->next = headPtr;
                headPtr = newPtr;
            }
            else
            {
                prevPtr->next = newPtr;
                newPtr ->next = currentPtr;
            }
            strcpy (newPtr->address , SPtr->address);
            strcpy (newPtr->birth ,SPtr ->birth );
            strcpy (newPtr->education, SPtr->education);
            strcpy(newPtr->gender , SPtr->gender);
            strcpy(newPtr->name , SPtr ->name);
            newPtr ->num = SPtr->num;
            strcpy(newPtr->phone, SPtr ->phone);
            strcpy (newPtr ->position ,SPtr ->position);
            newPtr->wage = SPtr->wage;

            SPtr=SPtr->next;
        }
        else
            printf("OUT OF MEMORY \n");                           
    }
display(headPtr);
}


/*按照车号排序*/
int queryByWage (inforPtr original , inforPtr creat)
{
    return original->wage < creat ->wage;
}

/*保存到文件*/
void save (inforPtr *sPtr)
{
    FILE *fPtr;
    inforPtr SPtr;
    SPtr=*sPtr;

    if ( (fPtr=fopen("data.dat","wb++")) !=NULL)
    {
        while (SPtr !=NULL)
        {
        fwrite(SPtr ,sizeof( struct information) , 1 ,fPtr);
        SPtr=SPtr->next;
        }
   
    }
    else
    {
        printf("File can not open!\n\n");
        exit(0);
    }

    fclose(fPtr);
    printf("\n*****自动保存成功!*****\n\n");

}

void load ( inforPtr *sPtr)
{
    FILE *fPtr;
    infor newList ;
    inforPtr currentPtr = NULL;
    inforPtr headPtr = NULL;
    inforPtr newPtr = NULL;
    inforPtr prevPtr = NULL;
    int verify=-100;
    struct _stat verifyFile;

    if ( (fPtr=fopen("data.dat","rb++")) == NULL)
    {
        if ( (fPtr=fopen("data.dat","wb++")) == NULL)
            printf("File can not open");
        else
            printf (    "\n欢迎首次使用,本系统所有数据将自动保存!\n"     );                    
    }
    else
    {   
        stat("data.dat",&verifyFile);

        if (verifyFile.st_size != 0)
        {


        headPtr=NULL;
        newPtr= NULL;
        currentPtr = NULL;

        while(!feof(fPtr))
        {
            fread(&newList, sizeof(struct information),1,fPtr);

    /*    printf("%-5.3d%-10s%-10s%-10s%-15s%-10s%-10.2lf%-20s%s\n",newList.num, newList.name, newList.birth, newList.gender, newList.education,
        newList.position, newList.wage, newList.address, newList.phone);
        */
            if(verify != newList.num)
            {
                if( ( newPtr = ( struct information *) malloc ( sizeof (struct information) ) ) != NULL)
                {
                    prevPtr = NULL;
                    currentPtr = headPtr;
                    newPtr->next = NULL;
               
                        while( currentPtr != NULL && newList.num>currentPtr->num)
                        {
                            prevPtr = currentPtr;
                            currentPtr = currentPtr ->next ;
                        }
                        if ( prevPtr == NULL)
                        {
                            newPtr->next = headPtr;
                            headPtr = newPtr;
                        }
                        else
                        {
                            prevPtr->next = newPtr;
                            newPtr ->next = currentPtr;
                        }
                    
                                strcpy (newPtr->address , newList.address);
                                strcpy (newPtr->birth ,newList.birth );
                                strcpy (newPtr->education, newList.education);
                                strcpy(newPtr->gender , newList.gender);
                                strcpy(newPtr->name , newList.name);
                                newPtr ->num = newList.num;
                                strcpy(newPtr->phone, newList.phone);
                                strcpy (newPtr ->position ,newList.position);
                                newPtr->wage = newList.wage;
                                verify = newList.num;
                }  /* END IF ALLOC */
            }   /* END IF VERIFY */
        }  /*END WHILE */

        *sPtr=headPtr;  /*把文件头传递到main*/
        fclose(fPtr);
        printf("\n********读取 \"数据库\" 成功!********\n\n");
        }//end stat if
    } /*end else*/
}
   
void del (inforPtr *sPtr,int value)
{
    inforPtr currentPtr;
    inforPtr prevPtr;

    currentPtr= *sPtr;
    prevPtr =NULL;

    while (currentPtr != NULL &&  value != currentPtr ->num)
    {
        prevPtr = currentPtr;
        currentPtr = currentPtr ->next;
    }
    if (prevPtr == NULL)
    {
        *sPtr=currentPtr->next;
    }
    else
    {
        prevPtr->next = currentPtr->next;
    }
    save(sPtr);
2013-12-19 13:04
q675802951
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-7-15
收藏
得分:0 
感谢楼主~~~
2015-07-15 10:26
脑掺半斤水ii
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-3-21
收藏
得分:0 
厉害👍👍👍👍👍,正需要,拿走了
2015-07-22 15:05
快速回复:学生管理系统、职工管理系统类似xx管理系统题目的模板,有需要的拿去修 ...
数据加载中...
 
   



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

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