| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 941 人关注过本帖
标题:用身份证后六位怎么查找不了,修改也不行?
只看楼主 加入收藏
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
结帖率:70%
收藏
已结贴  问题点数:16 回复次数:6 
用身份证后六位怎么查找不了,修改也不行?
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int num,i=0,m,zl;
float jbgzl,jbgz,shangxueqi,gongzi=0;
float xzbt,sysbz,ksf;     
     
struct lrx
{
    int num;                  
    char name[30];                    
    int leibie;
    float yuefen[12];
    char sfz[10];
    struct lrx *next;
};
struct lrx *xinjian()//指針函數
{
    struct lrx *p1,*p2,*head;
    int a=0;
    head=(struct lrx *)malloc(sizeof(struct lrx));
    head->num=a;
    p2=head;
    printf("請輸入員工信息\n");
    printf("编号:");
    scanf("%d",&num);
    while(num!=0)
    {
        p1=(struct lrx *)malloc(sizeof(struct lrx));
         p1->next=NULL;
        p1->num=num;
        printf("姓名:");
        scanf("%s",&p1->name);
        printf("身份證后六位:");
        scanf("%s",&p1->sfz);
        printf("员工类别(1-5):");
        scanf("%d",&zl);
        if(zl<1||zl>5)
        {
            printf("輸入錯誤!");
    }
    p1->leibie=zl;
        switch(zl)
        {
        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->yuefen[i]='\0';
                for(i=0;i<m;i++)
                    p1->yuefen[i]=gongzi;
                printf("录入成功!(输入0退出)\n");
                break;
        case 2:
                jbgz=650;
                sysbz=200;
                gongzi=jbgz+sysbz;
                for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                printf("录入成功!(输入0退出)\n");
                break;
        case 3:
                jbgz=750;
                xzbt=360;
                gongzi=jbgz+xzbt;
                for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    p1->yuefen[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->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[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->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                printf("录入成功!(输入0退出)\n");
                break;
        }
        
            p2->next=p1;
        
             p2=p1;
        printf("编号:");
        scanf("%d",&num);

  
    }
    return head;
}
void insert(struct lrx *head)
{
    struct lrx *p,*p1;
    p=head->next;   //指向链表头结点
    printf("请输入员工信息(輸入0返回主菜单)\n");
    printf("编号:");
    scanf("%d",&num);
    while(num!=0)
    {
        p1=(struct lrx *)malloc(sizeof(struct lrx));
         p1->next=NULL;
        p1->num=num;
        printf("姓名:");
        scanf("%s",&p1->name);
        printf("身份證后六位:");
        scanf("%s",&p1->sfz);
        printf("员工类别(1-5):");
        scanf("%d",&zl);
        if(zl<1||zl>5)
        {
            printf("輸入错误!(1-5):");
            

        }
        p1->leibie=zl;
        switch(zl)
        {
        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->yuefen[i]='\0';
                for(i=0;i<m;i++)
                    p1->yuefen[i]=gongzi;
                printf("添加成功!(输入0返回主菜单)\n");
                break;
            case 2:
                jbgz=650;
                sysbz=200;
                gongzi=jbgz+sysbz;
                for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                printf("添加成功!(输入0返回主菜单)\n");
                break;
            case 3:
                jbgz=750;
                xzbt=360;
                gongzi=jbgz+xzbt;
                for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    p1->yuefen[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->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[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->yuefen[i]='\0';
                printf("录入几个月的工资(1-12):");
                scanf("%d",&m);
                for(i=0;i<m;i++)
                    
                    p1->yuefen[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 lrx *del(struct lrx *head)
{
   struct lrx *p,*r;
   char sfz[10];
   char *name;
   //name=string;
   int s;
   p=head;
   if(p==NULL)
   {
       printf("该链表为空,无法删除");
       return head;
   }
  
   while(1)
   {
       printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
       printf("\t                     1.按编码删除                     ┃\n");
       printf("\t                     2.按身份證刪除                   ┃\n");
       printf("\t                     3.                           ┃\n");
       printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
       printf("请选择(1-3)==>");
       scanf("%d",&s);
       if(s>3||s<1)
       {
           printf("輸入错误,请重新选择(1-3)=>");
         
       }
       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",&sfz);
            while(sfz!=p->sfz&&p->next!=NULL)   
            {
                r=p;
                p=p->next;
            }
            if(sfz==p->sfz)
            {
               
                 r->next=p->next;
                 printf("删除成功\n");
            }
   
              else
             printf("没有该员工信息\n");
            break;   
       case 3:
           return head;
           break;
       }
   }

        return head;
   

            
   
}
struct lrx *xiugai(struct lrx *head)
{
    struct lrx *p1;
    char sfz[10];
    char *name;
    int s;
   // name=string;
    p1=head->next;
    while(1)
    {
       printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
       printf("\t                     1.按编码查找                     ┃\n");
       printf("\t                     2.按身份證查找                   ┃\n");
       printf("\t                     3.                           ┃\n");
       printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
       printf("请选择(1-3)==>");
       scanf("%d",&s);
       if(s>3||s<1)
       {
           printf("輸入错误,请重新选择(1-3)=>");
         
       }
       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->yuefen[i]);
                  printf("请重新输入该员工信息:");
                printf("编号:");
                  scanf("%d",&p1->num);
                 printf("姓名:");
                scanf("%s",&p1->name);
                 printf("员工类别(1-5):");
                scanf("%d",&zl);
                  if(zl<1||zl>5)
                {
                      printf("輸入错误!请重新选择(1-5):");
                  

                }
                p1->leibie=zl;
                switch(zl)
                {
                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->yuefen[i]='\0';
                    for(i=0;i<m;i++)
                    p1->yuefen[i]=gongzi;
                     printf("修改成功!\n");
                    break;
                case 2:
                      jbgz=650;
                    sysbz=200;
                    gongzi=jbgz+sysbz;
                    for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                     printf("修改成功!\n");
                     break;
               case 3:
                    jbgz=750;
                    xzbt=360;
                     gongzi=jbgz+xzbt;
                    for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                    printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    p1->yuefen[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->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->yuefen[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->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                     for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                    printf("修改成功!\n");
                    break;
                }
            }
            else
            printf("找不到该员工信息");
            break;
        case 2:
            p1=head->next;
            printf("请输入要修改的身份證:");
            scanf("%s",&sfz);
             while(sfz!=p1->sfz&&p1->next!=NULL)
             p1=p1->next;
            if(sfz==p1->sfz)
            {
                printf("员工原本信息:\n");
                printf("编号:%d\n",p1->num);
                   printf("姓名:%s\n",p1->name);
                 printf("身份證:%s\n",p1->sfz);
                  printf("类别:%d\n",p1->leibie);
                  for(i=0;i<12;i++)
                 printf("%d月工资:%f\n",i+1,p1->yuefen[i]);
                printf("请重新输入该员工信息:");
                printf("编号:");
                scanf("%d",&p1->num);
                printf("姓名:");
                 scanf("%s",&p1->name);
                printf("身份證后六位:");
                 scanf("%s",&p1->sfz);
                printf("员工类别(1-5):");
                scanf("%d",&zl);
                if(zl<1||zl>5)
                {
                 printf("輸入错误!请重新选择(1-5):");
               

                }
                p1->leibie=zl;
               switch(zl)
               {
                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->yuefen[i]='\0';
                    for(i=0;i<m;i++)
                    p1->yuefen[i]=gongzi;
                     printf("修改成功!\n");
                    break;
                case 2:
                      jbgz=650;
                    sysbz=200;
                    gongzi=jbgz+sysbz;
                    for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                     printf("修改成功!\n");
                     break;
                case 3:
                    jbgz=750;
                    xzbt=360;
                     gongzi=jbgz+xzbt;
                    for(i=0;i<12;i++)
                    p1->yuefen[i]='\0';
                    printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    p1->yuefen[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->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                    for(i=0;i<m;i++)
                    
                    p1->yuefen[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->yuefen[i]='\0';
                     printf("录入几个月的工资(1-12):");
                    scanf("%d",&m);
                     for(i=0;i<m;i++)
                    
                    p1->yuefen[i]=gongzi;
                    printf("修改成功!\n");
                    break;
               }
            }
            else
                printf("没找到该员工信息\n");
              break;   
        case 3:
            return head;
            break;
       }
   }
        return head;
}
int print(struct lrx *head)
{
   

    struct lrx *p;
    int i,s1,s;
    char *name;
    char sfz[10];
    //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                   1.查询员工信息                     ┃\n");
        printf("\t                   2. 返 回 主 菜 单                  ┃\n");
        printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
        printf("请选择(1-2)==>");
     scanf("%d",&m);
        if(m<1||m>2)
        {
               printf("輸入错误,请重新选择==>");
            
        }
        switch(m)
        {
            
            case 1:
                while(1)
                {
                printf("\t  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
                printf("\t                     1.按编码查询                     ┃\n");
                 printf("\t                     2.按身份證查询                   ┃\n");
                printf("\t                     3.                           ┃\n");
                printf("\t  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
                 printf("请选择(1-3)==>");
                scanf("%d",&s1);
                 if(m<1||m>3)
                {
                        printf("輸入错误,请重新选择==>");
                     
                }
                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("身份證:%s\n",p->sfz);
                              printf("类别:%d\n",p->leibie);
                             for(i=0;i<12;i++)
                              printf("%d月工资:%f\n",i+1,p->yuefen[i]);
                        }
                         else
                        printf("找不到该员工信息\n");
                        break;
                case 2:
                        p=head->next;
                        printf("请输入查询员工的身份證后六位:==>");
                        scanf("%s",&sfz);
                        while(s=p->sfz&&p->next!=NULL)
                         p=p->next;
                        if(sfz==p->sfz)
                       {
                            printf("编号:%d\n",p->num);
                              printf("姓名:%s\n",p->name);
                              printf("身份證:%s\n",p->sfz);
                              printf("类别:%d\n",p->leibie);
                            for(i=0;i<12;i++)
                             printf("%d月工资:%f\n",i+1,p->yuefen[i]);
                        }
                       else
                         printf("找不到该员工信息\n");
                        break;
                case 3:
                    goto b;
                    break;
                    
                }
                    }
                break;


             case 2:
                return 0;
                 break;

        }
   
    }
   
    return 0;
}
main()
{
    int i,s=0,b=0;
    struct lrx *head;
    head=NULL;
    printf("\t\t\t   首次使用请先初始化系统。\n");
    while(1)
    {
    printf ("*******************************************************************************\n");  
    printf ("**************************歡迎進入職工工資管理系統**************************** \n");
    printf ("*******************************************************************************\n");
    printf("\t                                                      \n");
    printf("\t                    1.查询员工信息                    \n");
    printf("\t                    2.添加员工信息                    \n");
    printf("\t                    3.修改员工信息                    \n");
    printf("\t                    4.删除员工信息                    \n");
    printf("\t                    5.初 始 化系统                    \n");
    printf("\t                    6.退出管理系统                    \n");
    printf("\t  ****************************************************\n");
    printf("\t  *  类别说明:                                        * \n");
    printf("\t  *         1.教师、2.实验员、3.行政人员              * \n");
    printf("\t  *          4.教师兼职实验员、5.行政人员兼职教师     * \n");
    printf("\t  ****************************************************\n");

    printf("请选择操作选项(1-5)==>");
     scanf("%d",&s);
    if(s>6||s<1)
    {    printf("輸入错误!请重新选择(1-5)==>");
        
    }
    switch(s)
    {
        case 1:
            print(head);
            break;
        case 2:
            insert(head);
            break;
        
        case 3:
            xiugai(head);
            break;
        case 4:
            del(head);
            break;
        case 5:
            head=xinjian();
            printf("初始化成功,请继续操作\n");
            break;
        case 6:
        
            exit(1);
            break;
   
    }
    }
               
}
搜索更多相关主题的帖子: 身份证 include 信息 
2014-06-10 18:17
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
收藏
得分:0 
搞掂,就加多个strcmp函数就系嘞。
2014-06-10 20:01
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:12 
本来就不需要把全部代码贴出来,这样说明对自己程序的机制其实不大清楚。顺便接分。

授人以渔,不授人以鱼。
2014-06-11 12:42
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
收藏
得分:0 
現在有個問題,用身份證刪除執行不了。
            case 2:
            p=head->next;
            printf("请输入要删除员工的身份證:");
               scanf("%s",&string);
            while(strcmp(p->sfz,sfz)!=0&&p->next!=NULL)   
            {
                r=p;
                p=p->next;
            }
            if(strcmp(p->sfz,sfz)!=0)
            {
               
                 r->next=p->next;
                 printf("删除成功\n");
            }
   
              else
             printf("没有该员工信息\n");
            break;   
2014-06-11 13:12
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
你这个程序的每个函数分解不彻底,纠缠太多。要删除一条记录,先把删除链表单条记录的函数提取出来写好,测试过了,然后在外面交互得到对应记录的指针,调用该删除函数即可。删除的部分没通过吧?

授人以渔,不授人以鱼。
2014-06-11 13:16
lrx2014
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2014-4-11
收藏
得分:0 
回复 5 楼 TonyDeng
知識有限,剛學鏈錶啊。你有更好的程序代碼可以給我看吶,我可以學習。可以寫出來就是不錯了。
2014-06-11 13:28
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
不服气指导你思考,那就不说好了,祝你学习别人的代码顺利。

授人以渔,不授人以鱼。
2014-06-11 13:30
快速回复:用身份证后六位怎么查找不了,修改也不行?
数据加载中...
 
   



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

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