| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 835 人关注过本帖
标题:
取消只看楼主 加入收藏
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
结帖率:70%
收藏
已结贴  问题点数:10 回复次数:1 
#include<stdio.h>
#include<stdlib.h>
#include"string.h"
#define NULL 0

    int num,i=0,m,kind;
    float jbgzl,jbgz,shangxueqi,gongzi=0;  //基本工作量,基本工资,上学期工作量,工资
    float xzbt,sysbz,ksf;     //行政补贴,实验室补助,课时费
struct node
{
    int num;
    char name[20];
    int leibie;
    float months[12];
    struct node *next;
};
struct node *creat()
{   
    struct node *p1,*p2;
    struct node *head;
    int n;
    head=(struct node *)malloc(sizeof(struct node));//设置一个空的头结点
    n=0;
    head->num=n;
    p2=head;
    printf("请输入员工信息(编号为0退出初始化)\n");
    printf("编号:");
    scanf("%d",&num);
    while(num!=0)
    {
        p1=(struct node *)malloc(sizeof(struct node));
         p1->next=NULL;
        p1->num=num;
        printf("姓名:");
        scanf("%s",&p1->name);
        printf("员工类别(1-5):");
        c:scanf("%d",&kind);
        if(kind<1||kind>5)
        {
            printf("错误!请重新选择(1-5):");
            goto c;

        }
        p1->leibie=kind;
        switch(kind)
        {
        case 1:
                jbgz=850;
                jbgzl=180;
                printf("请输入该员工上学期工作量:");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+ksf;
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                printf("录入成功,请继续录入下一个员工的信息(输入0退出初始化)\n");
                break;
            case 2:
                jbgz=650;
                sysbz=200;
                gongzi=jbgz+sysbz;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("录入成功,请继续录入下一个员工的信息(输入0退出初始化)\n");
                break;
            case 3:
                jbgz=750;
                xzbt=360;
                gongzi=jbgz+xzbt;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                printf("录入成功,请继续录入下一个员工的信息(输入0退出初始化)\n");
                break;
            case 4:
                jbgz=850;
                jbgzl=180;
                sysbz=200;
                printf("请输入该员工上学期工作量");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+ksf+sysbz;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("录入成功,请继续录入下一个员工的信息(输入0退出初始化)\n");
                break;
            case 5:
                jbgz=750;
                xzbt=360;
                jbgzl=180;
                printf("请输入该员工上学期工作量");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+xzbt+ksf;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("录入成功,请继续录入下一个员工的信息(输入0退出初始化)\n");
                break;
        }
        
            p2->next=p1;
        
             p2=p1;
        printf("编号:");
        scanf("%d",&num);

  
    }
    return head;
}
void insert(struct node *head)
{
    struct node *p,*p1;
    p=head->next;   //指向链表头结点
    printf("请输入员工信息(编号为0返回主菜单)\n");
    printf("编号:");
    scanf("%d",&num);
    while(num!=0)
    {
        p1=(struct node *)malloc(sizeof(struct node));
         p1->next=NULL;
        p1->num=num;
        printf("姓名:");
        scanf("%s",&p1->name);
        printf("员工类别(1-5):");
        c:scanf("%d",&kind);
        if(kind<1||kind>5)
        {
            printf("错误!请重新选择(1-5):");
            goto c;

        }
        p1->leibie=kind;
        switch(kind)
        {
        case 1:
                jbgz=850;
                jbgzl=180;
                printf("请输入该员工上学期工作量:");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+ksf;
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                printf("添加成功,请继续添加下一个员工的信息(输入0返回主菜单)\n");
                break;
            case 2:
                jbgz=650;
                sysbz=200;
                gongzi=jbgz+sysbz;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("添加成功,请继续添加下一个员工的信息(输入0返回主菜单)\n");
                break;
            case 3:
                jbgz=750;
                xzbt=360;
                gongzi=jbgz+xzbt;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                printf("添加成功,请继续添加下一个员工的信息(输入0返回主菜单)\n");
                break;
            case 4:
                jbgz=850;
                jbgzl=180;
                sysbz=200;
                printf("请输入该员工上学期工作量:");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+ksf+sysbz;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("添加成功,请继续添加下一个员工的信息(输入0返回主菜单)\n");
                break;
            case 5:
                jbgz=750;
                xzbt=360;
                jbgzl=180;
                printf("请输入该员工上学期工作量:");
                scanf("%f",&shangxueqi);
                ksf=(shangxueqi-jbgzl)*30;
                gongzi=jbgz+xzbt+ksf;
                for(i=0;i<12;i++)
                    p1->months[i]='\0';
                printf("需要录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                printf("添加成功,请继续添加下一个员工的信息(输入0返回主菜单)\n");
                break;
        }
        while(p->next!=NULL)   
            p=p->next;    //指向下一个结点
        if(p->next==NULL)
            p->next=p1; //将新结点链入尾结点
        p=p1;      
        printf("编号:");
        scanf("%d",&num);   
    }
 

}
struct node *del(struct node *head)
{
   struct node *p,*r;
   char string[20];
   char *name;
   name=string;
   int s;
   p=head;
   if(p==NULL)
   {
       printf("该链表为空,无法删除");
       return head;
   }
  
   while(1)
   {
       printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
       printf("\t                                                      ┃\n");
       printf("\t                     1.按编码删除                     ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t                     2.按名字删除                     ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t                     3.                           ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
       printf("请选择(1-3)==>");
z:       scanf("%d",&s);
       if(s>3||s<1)
       {
           printf("选择错误,请重新选择(1-3)=>");
           goto z;
       }
       switch(s)
       {
       case 1:
            p=head->next;
            printf("请输入要删除的员工编号:");
               scanf("%d",&num);
            while(num!=p->num&&p->next!=NULL)   
            {
                r=p;
                p=p->next;
            }
            if(num==p->num)
            {
                 r->next=p->next;
                 printf("删除成功\n");
            }
   
              else
             printf("没有该员工信息\n");
            break;
       case 2:
            p=head->next;
            printf("请输入要删除的员工姓名:");
               scanf("%s",&string);
            while(strcmp(p->name,name)!=0&&p->next!=NULL)   
            {
                r=p;
                p=p->next;
            }
            if(strcmp(p->name,name)==0)
            {
               
                 r->next=p->next;
                 printf("删除成功\n");
            }
   
              else
             printf("没有该员工信息\n");
            break;
       case 3:
           return head;
           break;
       }
   }

        return head;
   

            
   
}
struct node *xiugai(struct node *head)
{
    struct node *p1;
    char string[20];
    char *name;
    int s;
    name=string;
    p1=head->next;
    while(1)
    {
       printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
       printf("\t                                                      ┃\n");
       printf("\t                     1.按编码查找                     ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t                     2.按名字查找                     ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t                     3.                           ┃\n");
       printf("\t                                                      ┃\n");
       printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
       printf("请选择(1-3)==>");
z:       scanf("%d",&s);
       if(s>3||s<1)
       {
           printf("选择错误,请重新选择(1-3)=>");
           goto z;
       }
       switch(s)
       {
       case 1:
            p1=head->next;
            printf("请输入要修改的员工编号:");
            scanf("%d",&num);
             while(p1->num!=num&&p1->next!=NULL)
             p1=p1->next;
            if(p1->num==num)
            {
                printf("该员工本来信息:\n");
                printf("编号:%d\n",p1->num);
                   printf("姓名:%s\n",p1->name);
                  printf("类别:%d\n",p1->leibie);
                  for(i=0;i<12;i++)
                 printf("%d月工资:%f\n",i+1,p1->months[i]);
                  printf("请重新输入该员工信息:");
                printf("编号:");
                  scanf("%d",&p1->num);
                 printf("姓名:");
                scanf("%s",&p1->name);
                 printf("员工类别(1-5):");
                c:scanf("%d",&kind);
                  if(kind<1||kind>5)
                {
                      printf("错误!请重新选择(1-5):");
                   goto c;

                }
                p1->leibie=kind;
                switch(kind)
                {
                case 1:
                    jbgz=850;
                     jbgzl=180;
                      printf("请输入该员工上学期工作量:");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+ksf;
                    printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                    for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                    break;
                case 2:
                      jbgz=650;
                    sysbz=200;
                    gongzi=jbgz+sysbz;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                     break;
               case 3:
                    jbgz=750;
                    xzbt=360;
                     gongzi=jbgz+xzbt;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                    printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                    printf("修改成功\n");
                    break;
                case 4:
                      jbgz=850;
                    jbgzl=180;
                    sysbz=200;
                    printf("请输入该员工上学期工作量");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+ksf+sysbz;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                    break;
                case 5:
                     jbgz=750;
                    xzbt=360;
                    jbgzl=180;
                    printf("请输入该员工上学期工作量");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+xzbt+ksf;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                     for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                    printf("修改成功\n");
                    break;
                }
            }
            else
            printf("找不到该员工信息");
            break;
        case 2:
            p1=head->next;
            printf("请输入要修改的员工姓名:");
            scanf("%s",&string);
             while(strcmp(p1->name,name)!=0&&p1->next!=NULL)
             p1=p1->next;
            if(strcmp(p1->name,name)==0)
            {
                printf("该员工本来信息:\n");
                printf("编号:%d\n",p1->num);
                   printf("姓名:%s\n",p1->name);
                  printf("类别:%d\n",p1->leibie);
                  for(i=0;i<12;i++)
                 printf("%d月工资:%f\n",i+1,p1->months[i]);
                printf("请重新输入该员工信息:");
                printf("编号:");
                scanf("%d",&p1->num);
                printf("姓名:");
                 scanf("%s",&p1->name);
                printf("员工类别(1-5):");
              a:scanf("%d",&kind);
                if(kind<1||kind>5)
                {
                 printf("错误!请重新选择(1-5):");
                goto a;

                }
                p1->leibie=kind;
               switch(kind)
               {
                case 1:
                    jbgz=850;
                     jbgzl=180;
                      printf("请输入该员工上学期工作量:");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+ksf;
                    printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                    for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                    break;
                case 2:
                      jbgz=650;
                    sysbz=200;
                    gongzi=jbgz+sysbz;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                     break;
                case 3:
                    jbgz=750;
                    xzbt=360;
                     gongzi=jbgz+xzbt;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                    printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    p1->months[i]=gongzi;
                    printf("修改成功\n");
                    break;
                case 4:
                      jbgz=850;
                    jbgzl=180;
                    sysbz=200;
                    printf("请输入该员工上学期工作量");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+ksf+sysbz;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                     printf("修改成功\n");
                    break;
                case 5:
                     jbgz=750;
                    xzbt=360;
                    jbgzl=180;
                    printf("请输入该员工上学期工作量");
                    scanf("%f",&shangxueqi);
                    ksf=(shangxueqi-jbgzl)*30;
                    gongzi=jbgz+xzbt+ksf;
                    for(i=0;i<12;i++)
                    p1->months[i]='\0';
                     printf("需要录入几个月的工资(1-12):");
                    scanf("%d",&m);
                     for(i=0;i<m;i++)
                    
                    p1->months[i]=gongzi;
                    printf("修改成功\n");
                    break;
               }
            }
            else
                printf("没找到该员工信息\n");
              break;
        case 3:
            return head;
            break;
              



       }
   }
        return head;
        

}
int printf(struct node *head)
{
   

    struct node *p;
    int i,s1,s;
    char *name;
    char string[20];
    name=string;
    p=head->next;
    if(p==NULL)
    {
       printf("该链表为空\n");
       return 0;
    }
    if(p!=NULL)
b:    while(1)
    {
        p=head->next;
        printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
           printf("\t                                                      ┃\n");
        printf("\t                   1.查询全部员工信息                 ┃\n");
        printf("\t                                                      ┃\n");
        printf("\t                   2.查询单个员工信息                 ┃\n");
        printf("\t                                                      ┃\n");
        printf("\t                   3. 返 回 主 菜 单                  ┃\n");
        printf("\t                                                      ┃\n");
        printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
        printf("请选择(1-3)==>");
     s:scanf("%d",&m);
        if(m<1||m>3)
        {
               printf("选择错误,请重新选择==>");
            goto s;
        }
        switch(m)
        {
            case 1:
                 do
                 {
                    printf("编号:%d\n",p->num);
                       printf("姓名:%s\n",p->name);
                    printf("类别:%d\n",p->leibie);
                    for(i=0;i<12;i++)
                     printf("%d月工资:%f\n",i+1,p->months[i]);
                    p=p->next;
                 }while(p!=NULL);
                  break;
            case 2:
                while(1)
                {
                printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
                  printf("\t                                                      ┃\n");
                printf("\t                     1.按编码查询                     ┃\n");
                printf("\t                                                      ┃\n");
                 printf("\t                     2.按名字查询                     ┃\n");
                printf("\t                                                      ┃\n");
                printf("\t                     3.                           ┃\n");
                printf("\t                                                      ┃\n");
                printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
                 printf("请选择(1-3)==>");
                c:scanf("%d",&s1);
                 if(m<1||m>3)
                {
                        printf("选择错误,请重新选择==>");
                     goto c;
                }
                switch(s1)
                {
                case 1:
                        p=head->next;
                        printf("请输入查询员工的编码:==>");
                        scanf("%d",&s);
                         while(p->num!=s&&p->next!=NULL)
                         p=p->next;
                         if(s==p->num)
                        {
                            printf("编号:%d\n",p->num);
                            printf("姓名:%s\n",p->name);
                              printf("类别:%d\n",p->leibie);
                             for(i=0;i<12;i++)
                              printf("%d月工资:%f\n",i+1,p->months[i]);
                        }
                         else
                        printf("找不到该员工信息\n");
                        break;
                case 2:
                        p=head->next;
                        printf("请输入查询员工的姓名:==>");
                        scanf("%s",&string);
                        while(strcmp(p->name,name)!=0&&p->next!=NULL)
                         p=p->next;
                        if(strcmp(p->name,name)==0)
                       {
                            printf("编号:%d\n",p->num);
                              printf("姓名:%s\n",p->name);
                              printf("类别:%d\n",p->leibie);
                            for(i=0;i<12;i++)
                             printf("%d月工资:%f\n",i+1,p->months[i]);
                        }
                       else
                         printf("找不到该员工信息\n");
                        break;
                case 3:
                    goto b;
                    break;
                    
                }
                    }
                break;


             case 3:
                return 0;
                 break;

        }
   
    }
   
    return 0;
}

main()
{
    int i,s=0,b=0;
    struct node *head;
    head=NULL;
    printf("\t\t\t   首次使用请先初始化系统。\n");
    while(1)
    {
    printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
    printf("\t                                                      ┃\n");
    printf("\t               欢迎来到XX高校工资管理系统             ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t  ┣━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
    printf("\t                                                      ┃\n");
    printf("\t                    1.查询员工信息                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t                    2.添加员工信息                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t                    3.修改员工信息                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t                    4.删除员工信息                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t                    5.初 始 化系统                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t                    6.退出管理系统                    ┃\n");
    printf("\t                                                      ┃\n");
    printf("\t  ┣━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
    printf("\t  ┃类别说明:                                           ┃\n");
    printf("\t            1.教师、2.实验员、3.行政人员              ┃\n");
    printf("\t            4.教师兼职实验员、5.行政人员兼职教师      ┃\n");
    printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");

    printf("请选择您需要的操作选项(1-5)==>");
    a: scanf("%d",&s);
    if(s>6||s<1)
    {    printf("选择错误!请重新选择(1-5)==>");
        goto a;
    }
    switch(s)
    {
        case 1:
            printf(head);
            break;
        case 2:
            insert(head);
            break;
        
        case 3:
            xiugai(head);
            break;
        case 4:
            del(head);
            break;
        case 5:
            head=creat();
            printf("初始化成功,请继续操作\n");
            break;
        case 6:
            printf("Byebye\n");
            exit(1);
            break;
   
    }
   

   
    }

   





}
搜索更多相关主题的帖子: include 实验室 months 工作量 行政 
2014-06-09 17:48
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
收藏
得分:0 
我能跑出來,一開始不懂得什麼意思,現在大概知道了。
2014-06-09 20:55
快速回复:
数据加载中...
 
   



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

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