标题:利用C语言设计开发小型的员工工资管理信息系统。
只看楼主
晨簌馨
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2015-4-9
结帖率:100%
 问题点数:0 回复次数:9 
利用C语言设计开发小型的员工工资管理信息系统。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 3
int n=0;
typedef struct employee
{
 long num;    /*工号*/
  char name[50];  /*名字*/
  int age;     /*年龄*/
  char department[10];  /*部门*/
  int salary;/*工资*/
}EMPLOYEE;
int selectmenu();
void input(EMPLOYEE employee[]);     /*输入*/
void output(EMPLOYEE employee[]);    /*输出*/
void inquire(EMPLOYEE employee[]);    /*查询*/
int search(EMPLOYEE employee[],int n,long x);




EMPLOYEE employee[N];
void main()
{

   int password=123456;        
   int q;
   int w;
   printf("你只有一次录入密码的机会\n");
   printf("\n\n请输入密码:");
   scanf("%d",&w);
   printf("\n");
   if(password==w)
   {
      q=selectmenu();
       while(1)
       {
          switch(q)
          {
          case 1:
              input(employee);   break;       /*输入输入员工信息*/
          case 2:
              output(employee);    break;       /*显示员工信息*/
          case 3:
              inquire(employee);  break;        /*输入员工卡号来查询员工信息*/
         
 /*根据员工年龄来进行排序  */
          case 0:
              exit(0);     break;    /*退出*/
          }
         
          q=selectmenu();
       }
   }
   else
       printf("输入密码错误!\n");
}
int selectmenu()      /*菜单栏*/
{
    int q;
    printf("\n\n_________________________________________________________\n\n");
    printf("\n\n                        选择栏                         \n\n");
    printf("\t\n----------------------------------------------------------------------------\n");
    printf("\t\n********1.输入员工信息                                           ********");
    printf("\t\n********2.显示员工信息                                           ********");
    printf("\t\n********3.输入员工卡号来查询员工信息                             ********");
    printf("\t\n********4.根据员工年龄来进行排序                                 ********");
    printf("\t\n********0.退出程序                                               ********");
    printf("\t\n----------------------------------------------------------------------------\n");
    printf("\t请选择菜单号(0--4):");
    while((!scanf("%d",&q)||(q<0)||(q>4)))
    {
        printf("输入有误,请重新输入");
        printf("\n\n_________________________________________________________\n\n");
        printf("\n\n                        选择栏                         \n\n");
        printf("\t\n----------------------------------------------------------------------------\n");
        printf("\t\n********1.输入员工信息                                           ********");
        printf("\t\n********2.显示员工信息                                           ********");
          printf("\t\n********3.输入员工卡号来查询员工信息                             ********");
        printf("\t\n********4.根据员工年龄来进行排序                                 ********");
        printf("\t\n********0.退出程序                                               ********");
        printf("\t\n----------------------------------------------------------------------------\n");
        printf("\t请选择菜单号(0--4):");
    }
    return q;
}
void input(EMPLOYEE employee[])
{
   int n;
   printf("\n有多少名员工:");
   scanf("%d",&n);
    do
    {
            printf("\n输入员工工号(按0结束录入):");
             scanf("%ld",&employee[n].num);
              if(employee[n].num==0)    break;
        for(int i=0;i<n;i++)
        {
        
           while(employee[n].num==employee[i].num)
           {
               printf("\n该员工已经录入,请重新录入:");
               scanf("%ld",&employee[n].num);
               if(employee[n].num==0)   break;
               
           }
               printf("\n输入员工姓名:");
        scanf("%s",&employee[i].name);
        printf("\n输入员工年龄:");
        scanf("%d",&employee[i].age);
        if((employee[i].age<18)||(employee[i].age>60))
        {
            printf("\n员工年龄超出年龄范围18-60岁,请重新输入:");
        scanf("%d",&employee[i].age);
         
        }
        printf("\n输入员工工作部门:");
        scanf("%s",&employee[i].department );
        printf("\n输入员工工资:");
        scanf("%d",&employee[i].salary);
    n++;
        }
   
        printf("\n");
    }while(n<=20);
        printf("\n\n-------------------------------------------------------------\n\n");
}
void output(EMPLOYEE employee[])
{

       printf("\n\n-------------------------------------------------------------\n\n");
    printf("\n                             员工信息  \n\n\n");
    printf("工号\t姓名\t年龄\t部门\t工资\t\n");
    for(int i=0;i<n;i++)
    {
    printf("%ld\t%s\t%d\t%s\t%d\t",employee[n].num,employee[n].name,employee[n].age,employee[n].department,employee[n].salary);
    }
       printf("\n\n-------------------------------------------------------------\n\n");


}
void inquire(EMPLOYEE employee[])
{
     long x;
     printf("输入员工卡号:");
     scanf("%ld",&x);
     int p;
     p=search(employee,n,x);
     if(p!=-1)
     {
        printf("    员工姓名:%s\t\n",employee[p].name);
        printf("    员工年龄:%d\t\n",employee[p].age );
        printf("    员工部门:%s\t\n",employee[p].department );
        printf("    员工工资:%d\t\n",employee[p].salary );
     }
     else
     {
         printf("没有此员工信息");
     }
}
int search(EMPLOYEE employee[],int n,long x)
{
     int i;
      for(i=0;i<n;i++)
    {
        if(employee[i].num==x)
            return(i);
    }
    return -1;
}



想编一套员工工资管理系统,但是好像出了问题,求大神帮我看看,哪里有问题。没出错误
搜索更多相关主题的帖子: department employee include search C语言 
2015-05-30 13:33
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2276
专家分:10647
注 册:2015-3-19
得分:0 
void input(EMPLOYEE employee[])
{
   int j=0;
   printf("\n有多少名员工:");
   scanf("%d",&n);
    do{
            printf("\n输入员工工号(按0结束录入):");
             scanf("%ld",&employee[n].num);
              if(employee[n].num==0)    break;
        for(int i=0;i<n;i++){
           while(employee[n].num==employee[i].num){
               printf("\n该员工已经录入,请重新录入:");
               scanf("%ld",&employee[n].num);
               if(employee[n].num==0)   break;
               
           }
               printf("\n输入员工姓名:");
        scanf("%s",&employee[i].name);
        printf("\n输入员工年龄:");
        scanf("%d",&employee[i].age);
        if((employee[i].age<18)||(employee[i].age>60)){
            printf("\n员工年龄超出年龄范围18-60岁,请重新输入:");
            scanf("%d",&employee[i].age);
        }
        printf("\n输入员工工作部门:");
        scanf("%s",&employee[i].department );
        printf("\n输入员工工资:");
        scanf("%d",&employee[i].salary);
         j++;
        }
   
        printf("\n");
    }while(j<n);
        printf("\n\n-------------------------------------------------------------\n\n");
}

剑栈风樯各苦辛,别时冰雪到时春
2015-05-31 13:07
晨簌馨
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2015-4-9
得分:0 
这个有一个错误
【Linking...
文.obj : error LNK2001: unresolved external symbol "void __cdecl input(struct employee * const,int)" (?input@@YAXQAUemployee@@H@Z)
Debug/文.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

文.exe - 1 error(s), 0 warning(s)】
2015-05-31 14:44
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2276
专家分:10647
注 册:2015-3-19
得分:0 
void input(EMPLOYEE employee[])
{
   int j=0;
   printf("\n有多少名员工:");
   scanf("%d",&n);
    do{
            printf("\n输入员工工号(按0结束录入):");
             scanf("%ld",&employee[j].num);
              if(employee[j].num==0)    break;
            int i=0;
           while(i<j){
               if(employee[j].num==employee[i].num){
                      printf("\n该员工已经录入,请重新录入:");
                      continue;
               }
               if(employee[j].num==0)   break;
               i++;
               
           }
               printf("\n输入员工姓名:");
          scanf("%s",employee[j].name);
          printf("\n输入员工年龄:");
          scanf("%d",&employee[j].age);
          if((employee[i].age<18)||(employee[i].age>60)){
            printf("\n员工年龄超出年龄范围18-60岁,请重新输入:");
            scanf("%d",&employee[j].age);
         }
        printf("\n输入员工工作部门:");
        scanf("%s",employee[j].department );
        printf("\n输入员工工资:");
        scanf("%d",&employee[j].salary);
        
         j++;
   
        printf("\n");
    }while(j<n);
        printf("\n\n-------------------------------------------------------------\n\n");
}
void output(EMPLOYEE employee[])
{

       printf("\n\n-------------------------------------------------------------\n\n");
    printf("\n                             员工信息  \n\n\n");
    printf("工号\t姓名\t年龄\t部门\t工资\t\n");
    for(int i=0;i<n;i++)
    {
    printf("%ld\t%s\t%d\t%s\t%d\n",employee[i].num,employee[i].name,employee[i].age,employee[i].department,employee[i].salary);
    }
       printf("\n\n-------------------------------------------------------------\n\n");


}

剑栈风樯各苦辛,别时冰雪到时春
2015-05-31 15:04
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2276
专家分:10647
注 册:2015-3-19
得分:0 
第一个input函数里
 do{
            printf("\n输入员工工号(按0结束录入):");
             scanf("%ld",&employee[j].num);
              if(employee[j].num==0)    break;
            int i=0;
       while(i<j){
               if(employee[j].num==employee[i].num){
                      printf("\n该员工已经录入,请重新录入:");
                      continue;
               }  

改成:
 top: do{
            printf("\n输入员工工号(按0结束录入):");
             scanf("%ld",&employee[j].num);
              if(employee[j].num==0)    break;
            int i=0;
           while(i<j){
               if(employee[j].num==employee[i].num){
                      printf("\n该员工已经录入,请重新录入:");
                      goto top;
               }

剑栈风樯各苦辛,别时冰雪到时春
2015-05-31 15:10
jxb8888
Rank: 2
等 级:论坛游民
帖 子:21
专家分:32
注 册:2015-4-28
得分:0 
亲,我想问一下,你这是用结构数组的搞法吗?
2015-06-06 15:24
jxb8888
Rank: 2
等 级:论坛游民
帖 子:21
专家分:32
注 册:2015-4-28
得分:0 
结构数组的长度,你声明的是 N 3
2015-06-06 15:25
jxb8888
Rank: 2
等 级:论坛游民
帖 子:21
专家分:32
注 册:2015-4-28
得分:0 
只有3个员工?
你这一编译,给别人用,不是坑爹嘛,
2015-06-06 15:27
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2276
专家分:10647
注 册:2015-3-19
得分:0 
回复 8楼 jxb8888
楼上的高手我觉得你的问题很对,那么解决这个问题需要花多长时间?需要什么样的水平?
结构数组的搞法,你觉得不合适可以改成哈夫曼树红黑树也行啊。
当然觉得我说的不对欢迎指正。

剑栈风樯各苦辛,别时冰雪到时春
2015-06-06 15:31
jxb8888
Rank: 2
等 级:论坛游民
帖 子:21
专家分:32
注 册:2015-4-28
得分:0 
直接上链表,走起,想多少个员工就可以多少员工
2015-06-09 10:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-445992-1-1.html




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

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