工资管理系统C语言

Python020

工资管理系统C语言,第1张

代码还没有完善好,实在没时间了,最近太忙。先给你吧

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

int addmenu()

int menu()

typedef struct teacher{

char name[32]

char unit[32]

float salary

float allowance

float tax

float total

struct teacher *next

}TEACHER//节点的结构体,包含数据和指针.

TEACHER *head//头节点

void init() //初始化头节点

{

head=(TEACHER *)malloc(sizeof(TEACHER))

head->next=NULL

}

void add(TEACHER *nod) //添加节点

{

if(head->next==NULL){

head=nod

}

else

{

nod->next=head->next

head->next=nod

}

}

TEACHER *search(char *s) //遍历整个链表并打印数据

{

TEACHER *nod=head

while(nod->next !=NULL)//!循环到最后一个节点,有问题。。

{

if((!strcmp(nod->name,s)) || (!strcmp(nod->unit,s))){

printf("姓名:%s\n单位:%s\n基本工资:%f\n津贴:%f\n扣税:%f\n总工资:%f\n",nod->name,nod->unit,nod->salary,nod->allowance,nod->tax,nod->tax)

return nod

}

nod++

}

printf("未找到数据\n")

return NULL

}

void modify(TEACHER *s)

{

char name[16],unit[16]

float salary,allowance,tax,total

gets(name)

strcpy(s->name,name)

gets(unit)

strcpy(s->unit,unit)

scanf("%f",&salary)

s->salary=salary

scanf("%f",&allowance)

s->allowance=allowance

scanf("%f",&tax)

s->tax=tax

scanf("%f",&total)

s->total=total

}

void del(char *s)

{

TEACHER *nod=head

while(nod->next !=NULL)

{

if((!strcmp(nod->next->name,s))||(!strcmp(nod->next->unit,s))){

nod->next=nod->next->next

nod->next=NULL

}

}

}

int addmenu()//添加教师信息子菜单

{

TEACHER *node

char command

float salary,allowance,tax,total

system("cls")

printf("****************************\n")

printf("*添加子菜单*\n")

printf("****************************\n")

printf("说明:4.返回主菜单 5.添加\n")

printf("请选择需要使用的功能:")

fflush(stdin)

while((command=getchar())!='4')

{

if(command==4)

break

printf("添加信息:\n")

node=(TEACHER *)malloc(sizeof(TEACHER))

fflush(stdin)

printf("姓名:")

fflush(stdin)

gets(node->name)

printf("单位:")

fflush(stdin)

gets(node->unit)

printf("基本工资:")

fflush(stdin)

scanf("%f",&salary)

node->salary=salary

printf("津贴:")

scanf("%f",&allowance)

node->allowance=allowance

fflush(stdin)

printf("扣税:")

scanf("%f",&tax)

node->tax=tax

fflush(stdin)

printf("总工资:")

scanf("%f",&total)

node->total=total

fflush(stdin)

add(node)

fflush(stdin)

printf("输入c退出,其他字符继续\n")

if((command=getchar())=='c')

break

}

return 0

}

int save()

{

TEACHER *nod=head

FILE *fp

if((fp=fopen("teacher.txt","w+")) == NULL)

{

printf("打开文件异常\n")

return 0

}

while(nod->next != NULL)

{

if(fwrite(nod,sizeof(TEACHER),1,fp)!=1){

printf("写入异常\n")

return 0

}

nod++

}

fclose(fp)

return 1

}

int searchmenu()

{

char name[16]

char command

system("cls")

printf("****************************\n")

printf("* 查询和修改子菜单*\n")

printf("****************************\n")

printf("说明:4.返回主菜单 5.通过姓名/查找 6.修改 \n")

fflush(stdin)

printf("请输出需要实现的操作:")

while((command=getchar()) !='4')

{

switch(command)

{

case '4': break

case '5':

printf("请输入需要查找的姓名:")

fflush(stdin)

gets(name)

search(name)

break

// case '6': modify()break

}

printf("请输出需要实现的操作:")

}

return 0

}

int menu()

{

char command

int i,j=10

system("cls")

printf("****************************\n")

printf("* 工资管理系统 *\n")

printf("****************************\n")

printf("----------------------------\n")

printf("说明:1.添加 2.查询/修改 3.保存 4.退出\n")

printf("----------------------------\n")

printf("请输出需要实现的操作:")

while((command=getchar())!='4'){

switch(command)

{

case '1': addmenu()break

case '2': searchmenu()break

case '3': i=save()if(i)printf("保存成功!\n")while(j--)break

}

fflush(stdin)

/*子函数退出后再次显示主界面*/

system("cls")

printf("****************************\n")

printf("* 工资管理系统 *\n")

printf("****************************\n")

printf("----------------------------\n")

printf("说明:1.添加 2.查询/修改 3.保存 4.退出\n")

printf("----------------------------\n")

printf("请输出需要实现的操作:")

}

printf("******感谢您使用本系统******\n")

return 0

}

int main()

{

init()

menu()

return 0

}

程序名称:工资管理系统

程序说明:

该系统在磁盘上储存了某单位上月全体员工的工资信息,对于每一位职工存储以下信息:

月份,职工编号,基本工资,津贴,岗贴,补贴,房贴,交通补贴,应发数,房租,储蓄,

会费,个人所得税,应扣数,实发数。

工资管理系统详细代码参考一下http://wenku.baidu.com/view/c9af1211cc7931b765ce15d3.html