c工資管理系統源碼
① c語言,編寫職工工資管理系統,求源代碼...急QWQ
用C語言不太現實,這樣的程序最好用高級語言環境,.NET,或者直接用access
② 求用C語言編寫一個工資管理系統程序的源代碼,要用鏈表編
這傢伙真牛,求一套程序給10分
我做一套程序,求了5條代碼,花了500分
③ c語言程序設計、工資管理系統
#include <stdio.h>
#include <malloc.h>
#include <string.h>
typedef struct
{
char num[10];
char name[20];
char date[15];
double pay;
}employee;
typedef struct node
{
employee p;
struct node *pre;
struct node *next;
}node,*linklist;
linklist head,last;
void setData(linklist p)
{
printf("編號:");
scanf("%s",&p->p.num);
printf("姓名:");
scanf("%s",&p->p.name);
printf("入職時間:");
scanf("%s",&p->p.date);
printf("工資:");
scanf("%lf",&p->p.pay);
}
void Insert(linklist p)
{
setData(p);
p->next=last;
last->pre->next=p;
p->pre=last->pre;
last->pre=p;
}
void Add()
{
char ch;
do
{
linklist p=(linklist)malloc(sizeof(node));
system("cls");
Insert(p);
printf("是否繼續?");
scanf(" %c",&ch);
}while(ch=='y'||ch=='Y');
}
linklist Qur(int method)
{
char ch[20];
linklist p=head->next;
if(method==0)
{
printf("選擇查詢方式:(1 姓名、2 年月)");
scanf("%d",&method);
}
if(method==1)
{
printf("輸入姓名:");
scanf("%s",ch);
while(p!=last)
{
if(strcmp(ch,p->p.name)==0) break;
p=p->next;
}
}
else if(method==2)
{
printf("輸入年月:");
scanf("%s",ch);
while(p!=last)
{
if(strcmp(ch,p->p.date)==0) break;
p=p->next;
}
}
if(p==last) {printf("未找到\n");system("pause");}
return p;
}
void Del()
{
linklist p=Qur(1);
if(p==last) return;
p->pre->next=p->next;
p->next->pre=p->pre;
free(p);
printf("刪除成功\n");
system("pause");
}
void Modify()
{
linklist p=Qur(1);
if(p==last) return ;
setData(p);
}
void printTitle()
{
printf("編號\t名稱\t入職日期\t工資\n");
}
void show(linklist p)
{
printf("%s\t%s\t%s\t%.2lf\n",p->p.num,p->p.name,p->p.date,p->p.pay);
}
void Sort()
{
linklist p,q;
for (p=head->next;p!=last;p=p->next)
{
for (q=p->next;q!=last;q=q->next)
{
if(p->p.pay<q->p.pay)
{
employee temp=p->p;
p->p=q->p;
q->p=temp;
}
}
}
printf("完成\n");
system("pause");
}
void Tongji()
{
linklist p=head->next;
Sort();
printTitle();
while(p!=last)
{
show(p);
p=p->next;
}
system("pause");
}
void Wrong()
{
printf("輸入錯誤!\n");
system("pause");
}
void menu(void)
{
system("cls");
printf("********工資管理系統*******\n");
printf("* *\n");
printf("* 1:添加 *\n");
printf("* 2:刪除 *\n");
printf("* 3:查詢 *\n");
printf("* 4:修改 *\n");
printf("* 5:統計 *\n");
printf("* 6:排序 *\n");
printf("* 0:退出 *\n");
printf("* *\n");
printf("*******************************\n");
}
int select()
{
int choose;
scanf("%d",&choose);
switch(choose)
{
case 1:Add();break;
case 2:Del();break;
case 3:
{
linklist p=Qur(0);
if(p!=last) {show(p);system("pause");}break;
}
case 4:Modify();break;
case 5:Tongji();break;
case 6:Sort();break;
case 0:break;
default:Wrong();break;
}
return choose;
}
void destroy()
{
linklist p=head->next;
while(p!=last)
{
head->next=p->next;
free(p);
p=head->next;
}
free(head);
free(last);
}
int main(void)
{
head=(linklist)malloc(sizeof(node));
last=(linklist)malloc(sizeof(node));
head->next=last;
last->next=NULL;
last->pre=head;
head->pre=NULL;
do
{
menu();
} while (select()!=0);
destroy();
return 0;
}
④ C語言 工資管理系統
這個要靠調試了,不過有時候調試可能還不如重寫快,可以幫寫
⑤ 職工工資管理系統,求C語言代碼
寫了沒
⑥ c語言編一個工資管理系統 本系統能夠方便、靈活地實現職工工資的輸入、添加、刪除等編輯操作以及查詢等
*/#include "stdafx.h"
#include "iostream"
#include "string"
#include "list"
#include "cassert"
using namespace std;/*
編號、姓名、部門、應付工資、保險、稅金、實付工資。
其中實付工資由公式計算得到:實付工資=應付工資 - 保險- 稅金
*/
struct employee{
string m_num;//編號
string m_name;//姓名
string m_dep;//部門
double m_salary;//應付工資
double m_insurance;//保險
double m_tax;//稅金
};/*
(1)錄入:輸入職工數據,其中「實付工資」通過計算得到;
(2)刪除:刪除指定的職工信息(輸入姓名,若找到則刪除該信息)
(3) 修改:允許對已經錄入的數據重新進行編輯、修改;
(4) 顯示:顯示全體職工數據;
(5)查詢:
a. 輸入職工姓名,顯示該職工的全部數據;
b. 輸入某部門值,顯示該部門職工的數據、工資總額、平均工資。
(6) 退出程序。
*/list<employee> emps;int _tmain(int argc, _TCHAR* argv[])
{
void print(const employee &e);
void input();
void del();
void mod();
void show_all();
void show_name();
void show_dep();cout<<"簡易職工薪水管理程序 by 做他\n";// delete this line
cout<<"版權沒有 請隨意復制或修改任何代碼\n";//delete this linecout<<"請選擇操作:1.錄入 2.刪除 3.修改 4.查詢 5.顯示所有員工 6.退出 :";
int choose=0;
cin>>choose;
assert(!cin.fail());
while (choose!=6)
{
if (choose==1) input();
if (choose==2) del();
if (choose==3) mod();
if (choose==4)
{
int choice=0;
cout<<"請選擇操作 1.按姓名查詢 2.按部門查詢 3.退出:";
cin>>choice;
if (choice==1) show_name();
if (choice==2) show_dep();
if (choice==3)
{
cout<<"請選擇操作:1.錄入 2.刪除 3.修改 4.查詢 5.顯示所有員工 6.退出 :";
cin>>choose;
assert(!cin.fail());
continue;
}
}
if (choose==5) show_all();
cout<<"請選擇操作:1.錄入 2.刪除 3.修改 4.查詢 5.顯示所有員工 6.退出 :";
cin>>choose;
assert(!cin.fail());
}
return 0;
}void print(const employee &e)
{
cout<<"編號:"<<e.m_num<<endl;
cout<<"姓名:"<<e.m_name<<endl;
cout<<"部門:"<<e.m_dep<<endl;
cout<<"保險:"<<e.m_insurance<<endl;
cout<<"稅金:"<<e.m_tax<<endl;
cout<<"應付工資:"<<e.m_salary<<endl;
cout<<"實付工資:"<<e.m_salary-e.m_insurance-e.m_tax<<endl;
}void input()
{
string num,name,dep;
double salary,ins,tax;
cout<<"請輸入員工編號:";
cin>>num;
cout<<"請輸入員工姓名:";
cin>>name;
cout<<"請輸入員工部門:";
cin>>dep;
cout<<"請輸入員工保險:";
cin>>ins;
assert(!cin.fail());
cout<<"請輸入員工稅金:";
cin>>tax;
assert(!cin.fail());
cout<<"請輸入員工應付工資:";
cin>>salary;
assert(!cin.fail());
employee temp;
temp.m_dep=dep;
temp.m_insurance=ins;
temp.m_name=name;
temp.m_num=num;
temp.m_salary=salary;
temp.m_tax=tax;
emps.push_back(temp);
cout<<"員工錄入操作完畢.\n";
}void del()
{
if (emps.size()==0)
{
cout<<"沒有員工記錄.\n";
return;
}
string name;
bool isfind=false;
cout<<"請輸入要刪除的員工姓名:";
cin>>name;
list<employee>::iterator iter;
for (iter=emps.begin();iter!=emps.end();iter++)
{
if (iter->m_name==name)
{
isfind=true;
emps.erase(iter);
cout<<"姓名為\""<<name<<"\"的員工記錄已刪除.\n";
return;
}
}
if (!isfind)
{
cout<<"沒有找到姓名為\""<<name<<"\"的員工.\n";
return;
}
}void mod()
{
if (emps.size()==0)
{
cout<<"員工記錄為空.\n";
return;
}
bool isfind=false;
string name;
cout<<"請輸入要修改的員工姓名:";
cin>>name;
list<employee>::iterator iter;
for (iter=emps.begin();iter!=emps.end();iter++)
{
if (iter->m_name==name)
{
isfind=true;
cout<<"姓名為\""<<name<<"\"的員工記錄已找到.\n";
break;
}
}
if (isfind)
{
string num,name,dep;
double tax,ins,salary;
print(*iter);
cout<<endl;
cout<<"請輸入新的員工編號:";
cin>>num;
cout<<"請輸入新的員工姓名:";
cin>>name;
cout<<"請輸入新的員工部門:";
cin>>dep;
cout<<"請輸入新的員工保險:";
cin>>ins;
assert(!cin.fail());
cout<<"請輸入新的員工稅金:";
cin>>tax;
assert(!cin.fail());
cout<<"請輸入新的員工工資:";
cin>>salary;
assert(!cin.fail());
iter->m_dep=dep;
iter->m_insurance=ins;
iter->m_name=name;
iter->m_num=num;
iter->m_salary=salary;
iter->m_tax=tax;
cout<<"1 員工記錄被成功修改.\n";
}
else
{
cout<<"沒有找到姓名為\""<<name<<"\"的員工記錄.\n";
}
}void show_all()
{
if (emps.size()==0)
{
cout<<"員工記錄為空.\n";
return;
}
cout<<"顯示全體員工數據:\n";
cout<<"--------------------\n";
list<employee>::iterator iter;
for(iter=emps.begin();iter!=emps.end();iter++)
{
cout<<endl;
print(*iter);
cout<<endl;
}
cout<<"--------------------\n";
}void show_name()
{
if (emps.size()==0)
{
cout<<"員工記錄為空.\n";
return;
}
bool isfind=false;
string name;
cout<<"請輸入要查詢的員工姓名:";
cin>>name;
list<employee>::iterator iter;
for(iter=emps.begin();iter!=emps.end();iter++)
{
if (iter->m_name==name)
{
isfind=true;
cout<<"姓名為\""<<name<<"\"的員工記錄已找到.\n";
print(*iter);
break;
}
}
if (!isfind)
{
cout<<"沒有找到姓名為\""<<name<<"\"的員工.\n";
return;
}
}void show_dep()
{
if (emps.size()==0)
{
cout<<"員工記錄為空.\n";
return;
}
double isfind=0.00;
double total_salary=0.00;
string dep;
cout<<"請輸入要查詢的部門名稱:";
cin>>dep;
cout<<"部門["<<dep<<"]的員工信息:\n";
cout<<"--------------------\n\n";
list<employee>::iterator iter;
for(iter=emps.begin();iter!=emps.end();iter++)
{
if (iter->m_dep==dep)
{
isfind++;
total_salary+=iter->m_salary;
print(*iter);
cout<<endl;
continue;
}
}
cout<<"--------------------\n";
if (isfind==0)
{
cout<<"沒有找到名稱為["<<dep<<"]的部門.\n";
}
else
{
cout<<"部門["<<dep<<"]工資統計:\n";
cout<<"工資總額:"<<total_salary<<endl;
cout<<"平均工資:"<<total_salary/isfind<<endl;
}
}
⑦ C語言編寫工資管理系統
這個可以幫你
⑧ 工資管理系統C語言
代碼還沒有完善好,實在沒時間了,最近太忙。先給你吧
#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;
}
⑨ 求C語言 工資管理系統 原代碼
#include <iostream>
#include <string>
#define MaxHEAP 100
using namespace std;
class Elem{
private:
int objectID;
int priority;
string proName;
public:
Elem(int objectID=0,int priority=0){
setID(objectID);
setPri(priority);
setProN(proName);
}
int getID(){
return objectID;
}
int getPri(){
return priority;
}
string getProN(){
return proName;
}
void setID(int id){
objectID=id;
}
void setPri(int pri){
priority=pri;
}
void setProN(string s)
{
proName=s;
}
};
class Heap
{
private:
Elem items[MaxHEAP];
int size;
public :
Heap(){
Elem items[MaxHEAP];
setSize(0);}
void setSize(int sz)
{size=sz;}
int heapIsEmpty(){
return size==0;
}
void heapInsert(Elem newItem)
{if(size<MaxHEAP)
{
items[size]=newItem;
int place=size;
int parent=(place-1)/2;
while((parent>=0)&&(items[parent].getPri()<items[place].getPri()))
{
Elem temp=items[parent];
items[parent]=items[place];
items[place]=temp;
place=parent;
parent=(place-1/2);
}
++size;
}
heapRebuild(0);
}
Elem heapDelete(int ID)
{
Elem rootItem;
if(!heapIsEmpty())
{
for(int i=0;i<size;i++)
if(items[i].getID()==ID)
{rootItem=items[i];
swap(items[i],items[0]);
}
items[0]=items[--size];
heapRebuild(0);
}
else cout<<"\n錯誤:目錄為空"<<endl;
return rootItem;
}
void heapInit(){
setSize(0);
cout<<"空的項目"<<endl;}
void heapView(){
if(size==0){
cout<<"空的項目!"<<endl;
}
else{
cout<<"共有項目數: "<<size<<endl;
for(int ct=0;ct<size;ct++){
cout<<"ID: "<<items[ct].getID()<<" 優先順序: "<<items[ct].getPri()
<<" 工資數目: " <<items[ct].getProN()<<endl;
}
}
}
void search(int ID)
{ int N=0;
for(int i=0;i<size;i++)
if(items[i].getID()==ID)
{N++;
cout<<"ID: "<<items[i].getID()<<" 優先順序: "<<items[i].getPri()
<<" 名稱: " <<items[i].getProN()<<endl; }
if(!N) cout<<"未找到匹配的ID"<<endl;
}
void heapRebuild(int root)
{
int child=2*root+1;
if(child<size)
{
int rightChild=child+1;
if((rightChild<size)&&(items[rightChild].getPri()>=items[child].getPri()))
{child=rightChild;
}
if(items[root].getPri()<=items[child].getPri())
{
Elem temp=items[root];
items[root]=items[child];
items[child]=temp;
heapRebuild(child);
}
}
}
};
class priQueue
{private:
Heap h;
public:
priQueue(){
Heap();
}
int priIsEmpty(){
return h.heapIsEmpty();
}
void priInit(){
h.heapInit();
}
void priInsert(Elem newItem){
h.heapInsert(newItem);
}
Elem priDelete(int ID){
return h.heapDelete(ID);
}
void priView(){h.heapView();
}
void search(int ID)
{
h.search(ID);
}
};
void showMenu(){
cout<<"------------------------------------------------"<<endl;
cout<<"-----------------*工資管理系統*-----------------"<<endl;
cout<<"------------------------------------------------"<<endl;
cout<<" 1.重置"<<endl;
cout<<" 2.輸入"<<endl;
cout<<" 3.刪除"<<endl;
cout<<" 4.查詢"<<endl;
cout<<" 5.列印"<<endl;
cout<<" 0.退出"<<endl;
cout<<"------------------------------------------------"<<endl;
}
void showTip(){
cout<<"---------------------------------^_^--操作完成!"<<endl;
cout<<"------------------------------------選擇0-5繼續"<<endl;
}
int main(){
string i="-1";
int ID,PRI;
string proName;
Elem in;
priQueue PQ;
PQ.priInit();
system("cls");
showMenu();
cout<<"選擇菜單中的數字以便處理數據!"<<endl;
cin>>i;
system("cls");
while(i!="0")
{ if(i=="1")
{ system("cls");
showMenu();
cout<<"你選擇了1,項目將全部清空:"<<endl;
PQ.priInit();
showTip();
}
else if(i=="2")
{system("cls");
showMenu();
cout<<"你選擇了2,輸入ID,優先順序,工資"<<endl;
cout<<"輸入 ID(數字):"<<endl;
cin>>ID;
cout<<"輸入優先順序(數字):"<<endl;
cin>>PRI;
cout<<"輸入工資數目(數字):"<<endl;
cin>>proName;
in.setID(ID);
in.setPri(PRI);
in.setProN(proName);
PQ.priInsert(in);
showTip();
}
else if(i=="3")
{system("cls");
showMenu();
cout<<"你選擇了3,請選擇你要刪除的ID號"<<endl;
cin>>ID;
PQ.priDelete(ID);
showTip();
}
else if(i=="4")
{system("cls");
showMenu();
cout<<"你選擇了4,輸入要查找的項目ID號"<<endl;
cin>>ID;
PQ.search(ID);
showTip();
}
else if(i=="5")
{system("cls");
showMenu();
cout<<"你選擇了5,整個系統工資情況顯示如下:"<<endl;
PQ.priView();
showTip();
}
else {
system("cls");
showMenu();
cout<<"無效輸入!"<<endl;
}
cin>>i;
system("cls");
}
return 0;
}