㈠ 誰能寫個c語言論文稿參考-----職工信息管理系統設計
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
const N=50; // 定義系統可錄入的員工最大數值
string Ename[N];
long Enum[N];
char Esex[N];
int Eage[N];
char Emarriage[N];
int Edepart[N];
int Eposition[N];
int Edegree[50];
int Eworktime[N];
float Epay[N];
class Employee
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void NewInfo();
void ShowInfo();
void showall();
void showdepart(int depart);
void showdegree(int degree);
void showage(int min,int max);
void shownum(long number);
void RefreshInfo();
void DeleteInfo();
float Pay(int Employeegrade);
static int MaxNum();
};
class DBOperate
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void WriteIn(int iflag);
void ReadOut();
void RefreshMaxNum(int iflag); //i=1 or -1 or 0
};
long Employee::EmployeeMaxNum = 1000;
float Employee::EmployeeBasePay = 1500;
int Employee::MaxNum() //返回系統已經存儲的人數
{
int MN = 0;
ifstream myf;
myf.open("EmployeeMaxNum.txt");
myf>>MN;
cout<<MN<<endl;
myf.close();
return MN;
}
void Employee::NewInfo() //添加新成員函數
{
cout<<"新員工姓名: ";
cin>>Employee::Employeename;
Employee::Employeenum = EmployeeMaxNum + Employee::MaxNum()+1;
cout<<"新員工性別 (F為女性,M為男性): ";
cin>>Employee::Employeesex;
cout<<"新員工年齡: ";
cin>>Employee::Employeeage;
cout<<"新員工婚姻狀況(Y為已婚,N為未婚): ";
cin>>Employee::Employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號: "<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
while(Employee::Employeedegree !=1&&Employee::Employeedegree !=2&&Employee::Employeedegree !=3&&Employee::Employeedegree !=4&&Employee::Employeedegree !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士]";
cin>>Employee::Employeedegree;
}
cout<<"新員工所在部門,請輸入相應部門的序號:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
while(Employee::Employeedepart !=1&&Employee::Employeedepart !=2&&Employee::Employeedepart !=3&&Employee::Employeedepart !=4&&Employee::Employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
}
cout<<"新員工職位, 請輸入相應職位的序號: "<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
while(Employee::Employeeposition !=1&&Employee::Employeeposition !=2&&Employee::Employeeposition !=3&&Employee::Employeeposition !=4&&Employee::Employeeposition !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
}
cout<<"新員工的工作時(不需要輸入單位): ";
cin>>Employee::Employeeworktime;
Employee::Employeepay = Employee::Pay(Employee::Employeeposition);
DBOperate dbo;
dbo.ReadOut();
int MaxNum = Employee::MaxNum();
Enum[MaxNum] = Employee::Employeenum;
Ename[MaxNum] = Employee::Employeename;
Esex[MaxNum] = Employee::Employeesex;
Eage[MaxNum] = Employee::Employeeage;
Emarriage[MaxNum] = Employee::Employeemarriage;
Edegree[MaxNum] = Employee::Employeedegree;
Edepart[MaxNum] = Employee::Employeedepart;
Eposition[MaxNum] = Employee::Employeeposition;
Eworktime[MaxNum] = Employee::Employeeworktime;
Epay[MaxNum] = Employee::Employeepay;
dbo.WriteIn(1);
cout<<" 添加新成員成功!"<<endl;
return;
}
void Employee::ShowInfo() //程序主體 數據輸出函數
{
int choice1,choice2,min,max;
long searchnum;
Employee e;
cout<<" 請選擇查詢方式:"<<endl;
cout<<"******************************************"<<endl;
cout<<"* 輸出全體職工信息--------------------- 1"<<endl;
cout<<"* 按職工部門輸出----------------------- 2"<<endl;
cout<<"* 按職工學歷輸出----------------------- 3"<<endl;
cout<<"* 按職工年齡輸出----------------------- 4"<<endl;
cout<<"* 按職工編號輸出----------------------- 5"<<endl;
cout<<"******************************************"<<endl;
cin>>choice1;
switch(choice1)
{
case 1: showall();break;
case 2: cout<<"請輸入要查詢職工的部門編號: [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] " ;
cin>>choice2;
e.showdepart(choice2);break;
case 3: cout<<"請輸入要查詢職工的學歷編號: [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>choice2;
e.showdegree(choice2);break;
case 4: cout<<"請輸入要查詢的年齡范圍: ";
cout<<"最小值: ";
cin>>min;
cout<<"最大值: ";
cin>>max;
e.showage(min,max);break;
case 5: cout<<"請輸入要查詢的員工號: ";
cin>>searchnum;
e.shownum(searchnum);break;
default: cout<<"出錯啦! "<<endl;break;
}
}
void Employee::showall() //全體員工輸出函數
{ int i;
long number;
for(i=0;i<Employee::MaxNum();i++)
{
number = Enum[i];
shownum(number);
}
}
void Employee::showdepart(int depart) //按員工所在部門輸出函數
{
int i;
switch(depart)
{
case 1: cout<<"董事會的成員有: >"<<endl; break;
case 2: cout<<"市場部的成員有: >"<<endl; break;
case 3: cout<<"公關部的成員有: >"<<endl; break;
case 4: cout<<"客服中心成員有: >"<<endl; break;
case 5: cout<<"信息中心成員有: >"<<endl; break;
default: cout<<"輸入錯誤!>"<<endl; break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edepart[i] == depart)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showdegree(int degree) //按員工學歷輸出函數
{
int i;
switch(degree)
{
case 1:cout<<"初中學歷的員工有:"<<endl;break;
case 2:cout<<"高中學歷的員工有:"<<endl;break;
case 3:cout<<"本科學歷的員工有:"<<endl;break;
case 4:cout<<"碩士學位的員工有:"<<endl;break;
case 5:cout<<"博士學位的員工有:"<<endl;break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edegree[i] == degree)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showage(int min,int max) //按員工年齡段輸出函數
{
int i;
for(i=0;i<Employee::MaxNum();i++)
{
if(Eage[i]>=min&&Eage[i]<=max)
{
long number = Enum[i];
shownum(number);
}
else continue;
}
}
void Employee::shownum(long number) //按員工編號輸出函數
{
int i;
for(i=0;i<Employee::MaxNum();i++)
{
if(Enum[i] == number)
{
cout<<"**********************************"<<endl;
cout<<"員工編號 >"<<Enum[i]<<endl;
cout<<"姓 名 >"<<Ename[i]<<endl;
cout<<"性 別 >";
if(Esex[i]=='F') cout<<"女 "<<endl;
else if(Esex[i]=='M') cout<<"男 "<<endl;
cout<<"年 齡 >"<<Eage[i]<<"歲"<<endl;
cout<<"婚姻情況 >";
if(Emarriage[i]=='Y') cout<<"已婚 "<<endl;
else if(Emarriage[i]=='N') cout<<"未婚 "<<endl;
cout<<"學 歷 >";
switch (Edegree[i])
{
case 1:cout<<"初 中 "<<endl;break;
case 2:cout<<"高 中 "<<endl;break;
case 3:cout<<"本 科 "<<endl;break;
case 4:cout<<"碩 士 "<<endl;break;
case 5:cout<<"博 士 "<<endl;break;
}
cout<<"所在部門 >";
switch (Edepart[i])
{
case 1:cout<<"董事會 "<<endl;break;
case 2:cout<<"市場部 "<<endl;break;
case 3:cout<<"公關部 "<<endl;break;
case 4:cout<<"客服中心 "<<endl;break;
case 5:cout<<"信息中心 "<<endl;break;
}
cout<<"所任職務 >";
switch (Eposition[i])
{
case 1:cout<<"臨時成員 "<<endl;break;
case 2:cout<<"正式員工 "<<endl;break;
case 3:cout<<"主任 "<<endl;break;
case 4:cout<<"部門經理 "<<endl;break;
case 5:cout<<"董事長 "<<endl;break;
}
cout<<"工作時長 >"<<Eworktime[i]<<"小時"<<endl;
cout<<"額定工資 >"<<Epay[i]<<"元"<<endl;
cout<<"**********************************"<<endl;
}
else continue;
}
}
void Employee::RefreshInfo() //修改員工信息的函數
{
int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void Employee::shownum(long number);
cout<<"請輸入您要修改的員工編號: >";
cin>>cNum;
int MN;
MN = Employee::MaxNum();
for(int i=0;i<MN;i++) //遍歷數據文件,查找要修改的員工數據
{
if(Enum[i] == cNum)
{
Employee::shownum(cNum);
cout<<"請輸入該員工的新信息: "<<endl;
cout<<"新員工姓名: "; //錄入員工的新的數據,員工號保持不變
cin>>Employee::Employeename;
Ename[i] = Employee::Employeename;
cout<<"新員工性別: [F為女性,M為男性]: ";
cin>>Employee::Employeesex;
Esex[i] = Employee::Employeesex;
cout<<"新員工年齡: ";
cin>>Employee::Employeeage;
Eage[i] = Employee::Employeeage;
cout<<"新員工婚姻狀況(Y為已婚,N為未婚): ";
cin>>Employee::Employeemarriage;
Emarriage[i] = Employee::Employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
while(Employee::Employeedegree !=1&&Employee::Employeedegree !=2&&Employee::Employeedegree !=3&&Employee::Employeedegree !=4&&Employee::Employeedegree !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
}
Edegree[i] = Employee::Employeedegree;
cout<<"新員工所在部門,請輸入相應部門的序號: "<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
while(Employee::Employeedepart !=1&&Employee::Employeedepart !=2&&Employee::Employeedepart !=3&&Employee::Employeedepart !=4&&Employee::Employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
}
Edepart[i] = Employee::Employeedepart;
cout<<"新員工職位,請輸入相應職位的序號:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
while(Employee::Employeeposition !=1&&Employee::Employeeposition !=2&&Employee::Employeeposition !=3&&Employee::Employeeposition !=4&&Employee::Employeeposition !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
}
Eposition[i] = Employee::Employeeposition;
cout<<"新員工的工作時 (不需要輸入單位): ";
cin>>Employee::Employeeworktime;
Eworktime[i] = Employee::Employeeworktime;
Epay[i] = Employee::Pay(Employee::Employeeposition);
break;
}
}
dbo.WriteIn(0);
}
void Employee::DeleteInfo() //刪除員工數據的函數
{ char tmp;
int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void Employee::shownum(long number);
cout<<"請輸入您要修改的員工編號>: ";
cin>>cNum;
int MN;
MN = Employee::MaxNum();
for(int i=0;i<MN;i++) //遍歷數據文件,查找要刪除的員工
{
if(Enum[i] == cNum)
Employee::shownum(cNum);
}
cout<<"確認要刪除該員工信息?(Y為確認 N為放棄): ";
cin>>tmp;
if(tmp=='Y')
{
if(i==MN-1)
dbo.WriteIn(-1);
else
{
for(int j=i;j<MN-1;j++)
{ Enum[j] = Enum[j+1]; }
dbo.WriteIn(-1);
}
cout<<" 刪除操作成功 ! "<<endl;
}
}
float Employee::Pay(int Employeeposition) //根據員工職位計算工資的函數
{
float tmpPay;
tmpPay = Employee::EmployeeBasePay + Employee::Employeeposition * Employee::EmployeeBasePay;
return tmpPay;
}
void DBOperate::WriteIn(int iflag) //數據操作函數 寫入
{
DBOperate::RefreshMaxNum(iflag);
ofstream myf("Employee.txt");
Employee e;
int MN;
MN = e.MaxNum();
for(int i=0;i<MN;i++)
{
myf<<Enum[i]<<'\n'<<Ename[i]<<'\n'<<Esex[i]<<'\n'<<Eage[i]<<'\n'<<Emarriage[i]<<'\n'<<Edegree[i]<<'\n'<<Edepart[i]<<'\n'<<Eposition[i]<<'\n'<<Eworktime[i]<<'\n'<<Epay[i]<<'\n';
}
myf.close();
return;
}
void DBOperate::ReadOut() //數據操作函數 讀出
{
ifstream myf("Employee.txt");
Employee e;
int MN;
MN = e.MaxNum();
for(int i=0 ;i<MN;i++)
{
myf>>DBOperate::Employeenum>>DBOperate::Employeename>>DBOperate::Employeesex>>DBOperate::Employeeage>>DBOperate::Employeemarriage
>>DBOperate::Employeedegree>>DBOperate::Employeedepart>>DBOperate::Employeeposition>>DBOperate::Employeeworktime>>DBOperate::Employeepay;
Enum[i] = DBOperate::Employeenum;
Ename[i] = DBOperate::Employeename;
Esex[i] = DBOperate::Employeesex;
Eage[i] = DBOperate::Employeeage;
Emarriage[i] = DBOperate::Employeemarriage;
Edegree[i] = DBOperate::Employeedegree;
Edepart[i] = DBOperate::Employeedepart;
Eposition[i] = DBOperate::Employeeposition;
Eworktime[i] = DBOperate::Employeeworktime;
Epay[i] = DBOperate::Employeepay;
}
myf.close();
}
void DBOperate::RefreshMaxNum(int iflag) //更新系統中員工計數文件的函數
{
int MaxNum = 0;
ifstream myif("EmployeeMaxNum.txt");
myif>>MaxNum;
myif.close();
MaxNum = MaxNum+iflag;
ofstream myof("EmployeeMaxNum.txt");
myof<<MaxNum;
myof.close();
}
int main() //主函數
{
system("color 06f"); //設置當前窗口的背景色和前景色 0 = 黑色 8 = 灰色
// 1 = 藍色 9 = 淡藍色
// 2 = 綠色 A = 淡綠色
// 3 = 淺綠色 B = 淡淺綠色
// 4 = 紅色 C = 淡紅色
// 5 = 紫色 D = 淡紫色
// 6 = 黃色 E = 淡黃色
// 7 = 白色 F = 亮白色
int select = 0;
while(select!=5)
{
cout<<" ╭————————————《主菜單》———————————╮"<<endl;
cout<<" ∣ 請選擇功能 ∣"<<endl;
cout<<" ├————————————————————————————┤"<<endl;
cout<<" ∣ 1.新建並輸入職工數據 ∣"<<endl;
cout<<" ∣ 2.按條件輸出職工數據 ∣"<<endl;
cout<<" ∣ 3.修改指定職工的數據 ∣"<<endl;
cout<<" ∣ 4.刪除數據 ∣"<<endl;
cout<<" ∣ 5.退出 ∣"<<endl;
cout<<" ╰————————————————————————————╯"<<endl;
cout<<" ——————————————————————————————"<<endl;
cout<<" 請選擇您要服務的類別: " ;
cin>>select;
Employee e;
DBOperate dbo;
switch(select)
{
case 1:
e.NewInfo(); break;
case 2:
dbo.ReadOut();
e.ShowInfo(); break;
case 3:
e.RefreshInfo(); break;
case 4:
e.DeleteInfo(); break;
case 5: break;
default:
cout<<"命令錯誤!"<<endl;
}
if(select == 5)
break;
}
exit(1);
return 0;
}
這個是以前有過的例子,你按照這個修改一下,希望對你會有幫助.
㈡ 職工信息管理系統設計C語言
這個是一個學籍管理的代碼:
#include<stdio.h>
#include<windows.h>
#include<conio.h>
int add();
int amend();
int remove();
int show_student();
int show_class();
struct info //定義結構體info,用於存儲學生信息
{
char name[20]; //姓名
char sex[20]; //性別
char idcard[20]; //身份證號碼
char stuid[10]; //學號
char academe[20]; //學院
char specialty[20]; //專業
char classid[20]; //班級
char home[20]; //生源地
}stu[100];
int j=0;
int main(void) //主函數
{
/*登陸界面設計*/
char gongnengxuanzhe;
int flag=1;
system("cls");
printf("\n");
printf("\t\t\t\t 歡迎\n");
printf("\n\n\t尊敬的用戶, 非常感謝您使用本系統 , 您的完美體驗將是我們前進的方向 !\n\n\n");
printf("\t系統功能簡介:\n\n\n");
printf("\t\t①:通過鍵盤輸入某位學生的學生證信息。\n\n");
printf("\t\t②:給定學號,顯示某位學生的學生證信息。\n\n");
printf("\t\t③:給定某個班級的班號,顯示該班所有學生的學生證信息。\n\n");
printf("\t\t④:給定某位學生的學號,修改該學生的學生證信息。\n\n");
printf("\t\t⑤:給定某位學生的學號,刪除該學生的學生證信息。\n\n");
printf("\t\t⑥:按出生日期對全班學生的信息進行排序。\n\n\n");
printf("\t按任意鍵進入系統......");
getch();
do
{
system("cls");
printf("\n\n\n");
printf(" 尊敬的用戶 ,歡迎您使用本系統 !\n");
printf("\n\n\n");
printf(" 1.增加學生信息\n\n");
printf(" 2.修改學生信息\n\n");
printf(" 3.刪除學生信息\n\n");
printf(" 4.顯示單個學生信息\n\n");
printf(" 5.顯示整個班級學生信息\n\n");
printf(" 0.退出系統\n\n\n\n");
printf(" 請選擇您需要使用的功能:");
gongnengxuanzhe=getch();
switch(gongnengxuanzhe)
{
case '1':add();break;
case '2':amend();break;
case '3':remove();break;
case '4':show_student();break;
case '5':show_class();break;
case '0':flag=0;break;
default:
{
printf("\n\n 您的輸入有誤,請仔細閱讀使用說明!");
printf("\n 任意鍵繼續...");
getch();
}
}
}while(flag==1);
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t尊敬的用戶,非常感謝您的使用,您對於完美的追求是我們唯一的動力!");
printf("\n\n\t\t\t 按任意鍵退出系統......");
getch();
return 0;
}
int add() //增加學生信息函數
{
char flag='1';
do
{
system("cls");
printf("\n\t姓名:");
scanf("%s",&stu[j].name);
printf("\n\n\t性別:");
scanf("%s",&stu[j].sex);
printf("\n\n\t身份證號:");
scanf("%s",&stu[j].idcard);
printf("\n\n\t學院:");
scanf("%s",&stu[j].academe);
printf("\n\n\t專業:");
scanf("%s",&stu[j].specialty);
printf("\n\n\t班級:");
scanf("%s",&stu[j].classid);
printf("\n\n\t學號:");
scanf("%s",&stu[j].stuid);
printf("\n\n\t生源地:");
scanf("%s",&stu[j].home);
j++;
printf("\n\t繼續增加請鍵入1,返回請鍵入其他任意鍵:");
getchar();
flag=getchar();
}while(flag=='1');
return 0;
}
int amend() //修改學生信息函數
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系統無任何可以修改的記錄,請先行輸入數據!");
printf("\n\n\t\t\t 按任意鍵返回......");
getch();
return 0;
}
char a[20];
int z;
int flag=0;
do
{
system("cls");
printf("\n\t需要修改的學生學號:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
break; //break退出後,z++不會執行
}
}
if(flag==0)
{
printf("\t對不起,你請求學生信息不存在,請核實後重試!\n");
printf("\t按任意鍵繼續......");
getch();
}
}while(flag==0);
system("cls");
printf("\n\t姓名:");
scanf("%s",&stu[z].name);
printf("\n\n\t性別:");
scanf("%s",&stu[z].sex);
printf("\n\n\t身份證號:");
scanf("%s",&stu[z].idcard);
printf("\n\n\t學院:");
scanf("%s",&stu[z].academe);
printf("\n\n\t專業:");
scanf("%s",&stu[z].specialty);
printf("\n\n\t班級:");
scanf("%s",&stu[z].classid);
printf("\n\n\t學號:");
scanf("%s",&stu[z].stuid);
printf("\n\n\t生源地:");
scanf("%s",&stu[z].home);
return 0;
}
int remove() //刪除學生信息函數
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系統無任何可以刪除的記錄,請先行輸入數據!");
printf("\n\n\t\t\t 按任意鍵返回......");
getch();
return 0;
}
char a[20];
int z;
int x;
int flag=0;
do
{
system("cls");
printf("\n\t需要刪除的學生學號:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
for(x=z;x<j;x++)
{
strcpy(stu[x].name,stu[x+1].name);
strcpy(stu[x].sex,stu[x+1].sex);
strcpy(stu[x].idcard,stu[x+1].idcard);
strcpy(stu[x].academe,stu[x+1].academe);
strcpy(stu[x].specialty,stu[x+1].specialty);
strcpy(stu[x].classid,stu[x+1].classid);
strcpy(stu[x].stuid,stu[x+1].stuid);
strcpy(stu[x].stuid,stu[x+1].stuid);
}
j--;
printf("\n\t刪除成功!");
printf("\n\t按任意鍵返回上級菜單......");
getch();
}
}
if(flag==0)
{
printf("\t對不起,你請求學生信息不存在,請核實後重試!\n");
printf("\t按任意鍵繼續......");
getch();
}
}while(flag==0);
return 0;
}
int show_student() //單個顯示學生信息函數
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系統無任何可以顯示的記錄,請先行輸入數據!");
printf("\n\n\t\t\t 按任意鍵返回......");
getch();
return 0;
}
char a[20];
int z;
int flag=0;
do
{
system("cls");
printf("\n\t需要顯示的學生學號:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].stuid,a)==0)
{
flag=1;
system("cls");
printf("\n\t姓名:%s",stu[z].name);
printf("\n\n\t性別:%s",stu[z].sex);
printf("\n\n\t身份證號:%s",stu[z].idcard);
printf("\n\n\t學院:%s",stu[z].academe);
printf("\n\n\t專業:%s",stu[z].specialty);
printf("\n\n\t班級:%s",stu[z].classid);
printf("\n\n\t學號:%s",stu[z].stuid);
printf("\n\n\t生源地:%s",stu[z].home);
printf("\n\n\t按任意鍵返回上級菜單......");
getch();
}
}
if(flag==0)
{
printf("\t對不起,你請求顯示的學生信息不存在,請核實後重試!\n");
printf("\t按任意鍵繼續......");
getch();
}
}while(flag==0);
return 0;
}
int show_class() //顯示整個班級學生信息函數
{
if(j==0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t\t 系統無任何可以顯示的記錄,請先行輸入數據!");
printf("\n\n\t\t\t 按任意鍵返回......");
getch();
return 0;
}
char a[20];
int z;
int x;
int flag=0;
do
{
system("cls");
printf("\n\t需要顯示的班級號碼:");
scanf("%s",a);
for(z=0;z<j;z++)
{
if(strcmp(stu[z].classid,a)==0)
{
flag=1;
system("cls");
printf("\t%s %s 基本信息\n",stu[z].specialty,stu[z].classid);
for(x=0;x<j;x++)
{
if(strcmp(stu[x].classid,a)==0)
{
printf("\n\n\t姓名:%s",stu[z].name);
printf("\n\t性別:%s",stu[z].sex);
printf("\n\t身份證號:%s",stu[z].idcard);
printf("\n\t學院:%s",stu[z].academe);
printf("\n\t專業:%s",stu[z].specialty);
printf("\n\t班級:%s",stu[z].classid);
printf("\n\t學號:%s",stu[z].stuid);
printf("\n\t生源地:%s",stu[z].home);
}
}
printf("\n\n\t按任意鍵返回上級菜單......");
getch();
}
}
if(flag==0)
{
printf("\t對不起,你請求顯示的班級信息不存在,請核實後重試!\n");
printf("\t按任意鍵繼續......");
getch();
}
}while(flag==0);
return 0;
}
㈢ C語言程序——職工信息管理系統
貌似這么大的系統很難有人幫你做,這兒有個學生管理系統,稍加修改就成了~
/*學生成績管理系統*/
/*系統版本號:2006build 400.0201b*/
/*內核:adobo*/
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#define N 32
int total=N; //定義全局變數,學生的總個數total
struct student
{
int xh;
char xm[6];
int yw;
int sx;
int yy;
int jsj;
int zf;
};
struct student stu[N],temp;
char get_key() //得到用戶按鍵值
{
char key;
while (1)
{
if (kbhit())
{
key=getch();
break;
}
}
return key;
}
void wait() //按鍵等待,相當於PAUSE的功能
{
char key;
while (1)
{
if (kbhit())
{
key=getche();
break;
}
}
}
int id_search(int num) //查詢該學號學生的數組編號
{
int i;
for (i=0;i<total;i++)
if (stu[i].xh==num) break;
return i;
}
void show_one(int id) //顯示某學號學生的信息
{
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"⑴學號:"<<stu[id].xh<<endl;
cout<<"⑵姓名:"<<stu[id].xm<<endl;
cout<<"⑶語文:"<<stu[id].yw<<endl;
cout<<"⑷數學:"<<stu[id].sx<<endl;
cout<<"⑸英語:"<<stu[id].yy<<endl;
cout<<"⑹計算機:"<<stu[id].jsj<<endl;
cout<<"⑺總分:"<<stu[id].zf<<endl;
cout<<"--------------------------------------------------------------"<<endl;
}
void show_all() //顯示所有學生的信息
{
int i;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"學號\t"<<"姓名\t"<<"語文\t"<<"數學\t"<<"英語\t"<<"計算機\t"<<"總分"<<endl;
for (i=0;i<total;i++)
cout<<stu[i].xh<<'\t'<<stu[i].xm<<'\t'<<stu[i].yw<<'\t'<<stu[i].sx<<'\t'<<stu[i].yy<<'\t'<<stu[i].jsj<<'\t'<<stu[i].zf<<endl;
cout<<"--------------------------------------------------------------"<<endl;
}
void cj_input() //輸入學生的成績
{
int i;
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"※學生成績信息錄入菜單※"<<endl;
cout<<"◎請完整輸入學生個人信息"<<endl;
cout<<"◎學號項鍵入0可結束編輯"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
for (i=0;i<N;i++)
{
cout<<"請輸入第"<<i+1<<"個學生的學號:";
cin>>stu[i].xh;
if (stu[i].xh==0) return; //用戶輸入0時,結束編輯
cout<<"請輸入第"<<i+1<<"個學生的姓名:";
cin>>stu[i].xm;
cout<<"請輸入第"<<i+1<<"個學生的語文成績:";
cin>>stu[i].yw;
cout<<"請輸入第"<<i+1<<"個學生的數學成績:";
cin>>stu[i].sx;
cout<<"請輸入第"<<i+1<<"個學生的英語成績:";
cin>>stu[i].yy;
cout<<"請輸入第"<<i+1<<"個學生的計算機成績:";
cin>>stu[i].jsj;
stu[i].zf=stu[i].yw+stu[i].sx+stu[i].yy+stu[i].jsj;
cout<<"---------------提示:學號項鍵入 0可結束編輯----------------"<<endl;
}
}
void auto_input() //自動輸入學生的成績,為測試方便而設
{
int i;
for (i=0;i<N;i++)
{
stu[i].xh=(i+1);
strcpy(stu[i].xm,"ayc");
stu[i].yw=rand()%100;
stu[i].sx=rand()%100;
stu[i].yy=rand()%100;
stu[i].jsj=rand()%100;
stu[i].zf=stu[i].yw+stu[i].sx+stu[i].yy+stu[i].jsj;
}
}
void cj_modify() //學生成績的修改
{
int num,id;
char choice;
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"※學生成績信息修改菜單※"<<endl;
cout<<"◎請確認已經錄入學生信息"<<endl;
cout<<"◎學號不存在即會返回菜單"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"請輸入待修改的學生的學號:";
cin>>num;
id=id_search(num);
if (id==total)
{
cout<<endl;
cout<<"-〖系統提示〗------------------------"<<endl;
cout<<" 錯誤!無該學號學生信息!"<<endl;
cout<<"-------------------------------------"<<endl;
wait();
return;
}
cout<<"選擇要修改的項目的編號,其它值返回:";
show_one(id);
choice=get_key();
if (choice=='1')
{cout<<"輸入新的學號:";
cin>>stu[id].xh;
}
else if (choice=='2')
{cout<<"輸入新的姓名:";
cin>>stu[id].xm;
}
else if (choice=='3')
{cout<<"輸入新的語文成績:";
cin>>stu[id].yw;
}
else if (choice=='4')
{cout<<"輸入新的數學成績:";
cin>>stu[id].sx;
}
else if (choice=='5')
{cout<<"輸入新的英語成績:";
cin>>stu[id].yy;
}
else if (choice=='6')
{
cout<<"輸入新的計算機成績:";
cin>>stu[id].jsj;
}
stu[id].zf=stu[id].yw+stu[id].sx+stu[id].yy+stu[id].jsj;
if (choice=='1'||choice=='2'||choice=='3'||choice=='4'||choice=='5'||choice=='6')
{
cout<<"-〖系統提示〗------------------------"<<endl;
cout<<" 已成功修改該學生信息!";
cout<<"-------------------------------------"<<endl;
show_one(id);
wait();
}
}
void cj_delete() //學生信息的刪除
{
int num,id,i;
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"※學生成績信息刪除菜單※"<<endl;
cout<<"◎請確認已經錄入學生信息"<<endl;
cout<<"◎學號不存在即會返回菜單"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"請輸入要刪除的學生學號:";
cin>>num;
id=id_search(num);
if (id==total)
{
cout<<endl;
cout<<"-〖系統提示〗------------------------"<<endl;
cout<<" 錯誤!無該學號學生信息!"<<endl;
cout<<"-------------------------------------"<<endl;
wait();
return;
}
show_one(id);
for (i=id;i<total;i++)
stu[i]=stu[i+1];
total=total-1;
cout<<endl;
cout<<" 學 生 成 績 顯 示 菜 單 "<<endl;
show_all();
cout<<endl;
cout<<"-〖系統提示〗------------------------"<<endl;
cout<<" 已成功刪除該學生的信息!"<<endl;
cout<<"-------------------------------------"<<endl;
wait();
}
void func_1() //錄入編輯菜單
{
char choice;
while(1)
{
system("cls");
cout<<" 學 生 成 績 管 理 系 統 "<<endl;
cout<<"=============================================================="<<endl;
cout<<" ⑴錄入成績 "<<endl;
cout<<" ⑵修改成績 "<<endl;
cout<<" ⑶刪除成績 "<<endl;
cout<<" ⑷返回上級 "<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<" 鍵入相應數字項進行功能選擇(1-4) "<<endl;
choice=get_key();
if (choice=='1') cj_input(); //這里為測試方便,自動輸入了成績,注意改回
else if (choice=='2') cj_modify();
else if (choice=='3') cj_delete();
else if (choice=='4') break;
}
}
void show_person() //個人成績查詢
{
int num,id;
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"※學生成績信息修改菜單※"<<endl;
cout<<"◎請確認已經錄入學生信息"<<endl;
cout<<"◎學號不存在即會返回菜單"<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<"請輸入要查詢的學生學號:";
cin>>num;
id=id_search(num);
if (id==total)
{
cout<<endl;
cout<<"-〖系統提示〗------------------------"<<endl;
cout<<" 錯誤!無該學號學生信息!"<<endl;
cout<<"-------------------------------------"<<endl;
wait();
return;
}
show_one(id);
wait();
}
void cj_pm() //生成名次,即按照總分輸出
{
int i,j;
for (j=0;j<total;j++)
{
for (i=0;i<total-j;i++)
{
if (stu[i].zf<stu[i+1].zf)
{
temp=stu[i];
stu[i]=stu[i+1];
stu[i+1]=temp;
}
}
}
cout<<endl;
cout<<" 學 生 成 績 顯 示 (按 總 分) "<<endl;
show_all();
wait();
}
void cj_xh() //按照學號輸出
{
int i,j;
for (j=0;j<total;j++)
{
for (i=0;i<total-j;i++)
{
if (stu[i].xh>stu[i+1].xh)
{
temp=stu[i];
stu[i]=stu[i+1];
stu[i+1]=temp;
}
}
}
cout<<endl;
cout<<" 學 生 成 績 顯 示 (按 學 號) "<<endl;
show_all();
wait();
}
void cj_bk() //生成補考名單
{
int i;
cout<<" 補 考 名 單 "<<endl;
cout<<"=============================================================="<<endl;
cout<<"學號\t"<<"姓名\t"<<"語文\t"<<"數學\t"<<"英語\t"<<"計算機\t"<<endl;
for (i=0;i<total;i++)
{
if ((stu[i].yw<60)||(stu[i].sx<60)||(stu[i].yy<60)||(stu[i].jsj<60))
{
cout<<stu[i].xh<<'\t'<<stu[i].xm<<'\t';
if(stu[i].yw<60) cout<<"補考\t";
else cout<<'\t';
if(stu[i].sx<60) cout<<"補考\t";
else cout<<'\t';
if(stu[i].yy<60) cout<<"補考\t";
else cout<<'\t';
if(stu[i].jsj<60) cout<<"補考\t"<<endl;
else cout<<endl;
}
}
cout<<"--------------------------------------------------------------"<<endl;
wait();
}
void func_2() //成績查詢統計
{
char choice;
while(1)
{
system("cls");
cout<<" 學 生 成 績 管 理 系 統 "<<endl;
cout<<"=============================================================="<<endl;
cout<<" ⑴個人成績查詢 "<<endl;
cout<<" ⑵班級排名查詢 "<<endl;
cout<<" ⑶生成補考名單 "<<endl;
cout<<" ⑷返回上級 "<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<" 鍵入相應數字項進行功能選擇(1-4) "<<endl;
choice=get_key();
if (choice=='1') show_person();
else if (choice=='2') cj_pm();
else if (choice=='3') cj_bk();
else if (choice=='4') break;
}
}
void func_3() //成績列印與輸出
{
char choice;
while(1)
{
system("cls");
cout<<" 學 生 成 績 管 理 系 統 "<<endl;
cout<<"=============================================================="<<endl;
cout<<" ⑴按學號輸出 "<<endl;
cout<<" ⑵按總分輸出 "<<endl;
cout<<" ⑶返回上級 "<<endl;
cout<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<" 鍵入相應數字項進行功能選擇(1-3) "<<endl;
choice=get_key();
if (choice=='1') cj_xh();
else if (choice=='2') cj_pm();
else if (choice=='3') break;
}
}
int main() //主函數開始
{
char choice;
while(1)
{
system("cls");
cout<<" 學 生 成 績 管 理 系 統 "<<endl;
cout<<"=============================================================="<<endl;
cout<<" ⑴成績錄入與編輯 "<<endl;
cout<<" ⑵成績查詢與統計 "<<endl;
cout<<" ⑶成績列印與輸出 "<<endl;
cout<<" ⑷退出本管理系統 "<<endl;
cout<<"--------------------------------------------------------------"<<endl;
cout<<" 鍵入相應數字項進行功能選擇(1-4) "<<endl;
choice=get_key();
if (choice=='1') func_1();
else if (choice=='2') func_2();
else if (choice=='3') func_3();
else if (choice=='4') break;
}
system("cls"); //版權信息
cout<<"***************[關於本系統]***************"<<endl;
}
㈣ 急求C語言程序設計論文有一個 職工信息管理系統設計
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
const N=50; // 定義系統可錄入的員工最大數值
string Ename[N];
long Enum[N];
char Esex[N];
int Eage[N];
char Emarriage[N];
int Edepart[N];
int Eposition[N];
int Edegree[50];
int Eworktime[N];
float Epay[N];
class Employee
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void NewInfo();
void ShowInfo();
void showall();
void showdepart(int depart);
void showdegree(int degree);
void showage(int min,int max);
void shownum(long number);
void RefreshInfo();
void DeleteInfo();
float Pay(int Employeegrade);
static int MaxNum();
};
class DBOperate
{
public:
string Employeename;
long Employeenum;
char Employeesex;
int Employeeage;
char Employeemarriage;
int Employeedepart;
int Employeeposition;
int Employeedegree;
int Employeeworktime;
float Employeepay;
static long EmployeeMaxNum;
static float EmployeeBasePay;
void WriteIn(int iflag);
void ReadOut();
void RefreshMaxNum(int iflag); //i=1 or -1 or 0
};
long Employee::EmployeeMaxNum = 1000;
float Employee::EmployeeBasePay = 1500;
int Employee::MaxNum() //返回系統已經存儲的人數
{
int MN = 0;
ifstream myf;
myf.open("EmployeeMaxNum.txt");
myf>>MN;
cout<<MN<<endl;
myf.close();
return MN;
}
void Employee::NewInfo() //添加新成員函數
{
cout<<"新員工姓名: ";
cin>>Employee::Employeename;
Employee::Employeenum = EmployeeMaxNum + Employee::MaxNum()+1;
cout<<"新員工性別 (F為女性,M為男性): ";
cin>>Employee::Employeesex;
cout<<"新員工年齡: ";
cin>>Employee::Employeeage;
cout<<"新員工婚姻狀況(Y為已婚,N為未婚): ";
cin>>Employee::Employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號: "<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
while(Employee::Employeedegree !=1&&Employee::Employeedegree !=2&&Employee::Employeedegree !=3&&Employee::Employeedegree !=4&&Employee::Employeedegree !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士]";
cin>>Employee::Employeedegree;
}
cout<<"新員工所在部門,請輸入相應部門的序號:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
while(Employee::Employeedepart !=1&&Employee::Employeedepart !=2&&Employee::Employeedepart !=3&&Employee::Employeedepart !=4&&Employee::Employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
}
cout<<"新員工職位, 請輸入相應職位的序號: "<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
while(Employee::Employeeposition !=1&&Employee::Employeeposition !=2&&Employee::Employeeposition !=3&&Employee::Employeeposition !=4&&Employee::Employeeposition !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
}
cout<<"新員工的工作時(不需要輸入單位): ";
cin>>Employee::Employeeworktime;
Employee::Employeepay = Employee::Pay(Employee::Employeeposition);
DBOperate dbo;
dbo.ReadOut();
int MaxNum = Employee::MaxNum();
Enum[MaxNum] = Employee::Employeenum;
Ename[MaxNum] = Employee::Employeename;
Esex[MaxNum] = Employee::Employeesex;
Eage[MaxNum] = Employee::Employeeage;
Emarriage[MaxNum] = Employee::Employeemarriage;
Edegree[MaxNum] = Employee::Employeedegree;
Edepart[MaxNum] = Employee::Employeedepart;
Eposition[MaxNum] = Employee::Employeeposition;
Eworktime[MaxNum] = Employee::Employeeworktime;
Epay[MaxNum] = Employee::Employeepay;
dbo.WriteIn(1);
cout<<" 添加新成員成功!"<<endl;
return;
}
void Employee::ShowInfo() //程序主體 數據輸出函數
{
int choice1,choice2,min,max;
long searchnum;
Employee e;
cout<<" 請選擇查詢方式:"<<endl;
cout<<"******************************************"<<endl;
cout<<"* 輸出全體職工信息--------------------- 1"<<endl;
cout<<"* 按職工部門輸出----------------------- 2"<<endl;
cout<<"* 按職工學歷輸出----------------------- 3"<<endl;
cout<<"* 按職工年齡輸出----------------------- 4"<<endl;
cout<<"* 按職工編號輸出----------------------- 5"<<endl;
cout<<"******************************************"<<endl;
cin>>choice1;
switch(choice1)
{
case 1: showall();break;
case 2: cout<<"請輸入要查詢職工的部門編號: [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] " ;
cin>>choice2;
e.showdepart(choice2);break;
case 3: cout<<"請輸入要查詢職工的學歷編號: [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>choice2;
e.showdegree(choice2);break;
case 4: cout<<"請輸入要查詢的年齡范圍: ";
cout<<"最小值: ";
cin>>min;
cout<<"最大值: ";
cin>>max;
e.showage(min,max);break;
case 5: cout<<"請輸入要查詢的員工號: ";
cin>>searchnum;
e.shownum(searchnum);break;
default: cout<<"出錯啦! "<<endl;break;
}
}
void Employee::showall() //全體員工輸出函數
{ int i;
long number;
for(i=0;i<Employee::MaxNum();i++)
{
number = Enum[i];
shownum(number);
}
}
void Employee::showdepart(int depart) //按員工所在部門輸出函數
{
int i;
switch(depart)
{
case 1: cout<<"董事會的成員有: >"<<endl; break;
case 2: cout<<"市場部的成員有: >"<<endl; break;
case 3: cout<<"公關部的成員有: >"<<endl; break;
case 4: cout<<"客服中心成員有: >"<<endl; break;
case 5: cout<<"信息中心成員有: >"<<endl; break;
default: cout<<"輸入錯誤!>"<<endl; break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edepart[i] == depart)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showdegree(int degree) //按員工學歷輸出函數
{
int i;
switch(degree)
{
case 1:cout<<"初中學歷的員工有:"<<endl;break;
case 2:cout<<"高中學歷的員工有:"<<endl;break;
case 3:cout<<"本科學歷的員工有:"<<endl;break;
case 4:cout<<"碩士學位的員工有:"<<endl;break;
case 5:cout<<"博士學位的員工有:"<<endl;break;
}
for(i=0;i<Employee::MaxNum();i++)
{
if(Edegree[i] == degree)
{
long number = Enum[i];
shownum(number);
} else continue;
}
}
void Employee::showage(int min,int max) //按員工年齡段輸出函數
{
int i;
for(i=0;i<Employee::MaxNum();i++)
{
if(Eage[i]>=min&&Eage[i]<=max)
{
long number = Enum[i];
shownum(number);
}
else continue;
}
}
void Employee::shownum(long number) //按員工編號輸出函數
{
int i;
for(i=0;i<Employee::MaxNum();i++)
{
if(Enum[i] == number)
{
cout<<"**********************************"<<endl;
cout<<"員工編號 >"<<Enum[i]<<endl;
cout<<"姓 名 >"<<Ename[i]<<endl;
cout<<"性 別 >";
if(Esex[i]=='F') cout<<"女 "<<endl;
else if(Esex[i]=='M') cout<<"男 "<<endl;
cout<<"年 齡 >"<<Eage[i]<<"歲"<<endl;
cout<<"婚姻情況 >";
if(Emarriage[i]=='Y') cout<<"已婚 "<<endl;
else if(Emarriage[i]=='N') cout<<"未婚 "<<endl;
cout<<"學 歷 >";
switch (Edegree[i])
{
case 1:cout<<"初 中 "<<endl;break;
case 2:cout<<"高 中 "<<endl;break;
case 3:cout<<"本 科 "<<endl;break;
case 4:cout<<"碩 士 "<<endl;break;
case 5:cout<<"博 士 "<<endl;break;
}
cout<<"所在部門 >";
switch (Edepart[i])
{
case 1:cout<<"董事會 "<<endl;break;
case 2:cout<<"市場部 "<<endl;break;
case 3:cout<<"公關部 "<<endl;break;
case 4:cout<<"客服中心 "<<endl;break;
case 5:cout<<"信息中心 "<<endl;break;
}
cout<<"所任職務 >";
switch (Eposition[i])
{
case 1:cout<<"臨時成員 "<<endl;break;
case 2:cout<<"正式員工 "<<endl;break;
case 3:cout<<"主任 "<<endl;break;
case 4:cout<<"部門經理 "<<endl;break;
case 5:cout<<"董事長 "<<endl;break;
}
cout<<"工作時長 >"<<Eworktime[i]<<"小時"<<endl;
cout<<"額定工資 >"<<Epay[i]<<"元"<<endl;
cout<<"**********************************"<<endl;
}
else continue;
}
}
void Employee::RefreshInfo() //修改員工信息的函數
{
int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void Employee::shownum(long number);
cout<<"請輸入您要修改的員工編號: >";
cin>>cNum;
int MN;
MN = Employee::MaxNum();
for(int i=0;i<MN;i++) //遍歷數據文件,查找要修改的員工數據
{
if(Enum[i] == cNum)
{
Employee::shownum(cNum);
cout<<"請輸入該員工的新信息: "<<endl;
cout<<"新員工姓名: "; //錄入員工的新的數據,員工號保持不變
cin>>Employee::Employeename;
Ename[i] = Employee::Employeename;
cout<<"新員工性別: [F為女性,M為男性]: ";
cin>>Employee::Employeesex;
Esex[i] = Employee::Employeesex;
cout<<"新員工年齡: ";
cin>>Employee::Employeeage;
Eage[i] = Employee::Employeeage;
cout<<"新員工婚姻狀況(Y為已婚,N為未婚): ";
cin>>Employee::Employeemarriage;
Emarriage[i] = Employee::Employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
while(Employee::Employeedegree !=1&&Employee::Employeedegree !=2&&Employee::Employeedegree !=3&&Employee::Employeedegree !=4&&Employee::Employeedegree !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:初中 2:高中 3:本科 4:碩士 5:博士] ";
cin>>Employee::Employeedegree;
}
Edegree[i] = Employee::Employeedegree;
cout<<"新員工所在部門,請輸入相應部門的序號: "<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
while(Employee::Employeedepart !=1&&Employee::Employeedepart !=2&&Employee::Employeedepart !=3&&Employee::Employeedepart !=4&&Employee::Employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:董事會 2:市場部 3:公關部 4:客服中心 5:信息中心] ";
cin>>Employee::Employeedepart;
}
Edepart[i] = Employee::Employeedepart;
cout<<"新員工職位,請輸入相應職位的序號:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
while(Employee::Employeeposition !=1&&Employee::Employeeposition !=2&&Employee::Employeeposition !=3&&Employee::Employeeposition !=4&&Employee::Employeeposition !=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<" [1:臨時職員 2: 正式職員 3:主任 4:部門經理 5:董事長] ";
cin>>Employee::Employeeposition;
}
Eposition[i] = Employee::Employeeposition;
cout<<"新員工的工作時 (不需要輸入單位): ";
cin>>Employee::Employeeworktime;
Eworktime[i] = Employee::Employeeworktime;
Epay[i] = Employee::Pay(Employee::Employeeposition);
break;
}
}
dbo.WriteIn(0);
}
void Employee::DeleteInfo() //刪除員工數據的函數
{ char tmp;
int cNum = 1000;
DBOperate dbo;
dbo.ReadOut();
void Employee::shownum(long number);
cout<<"請輸入您要修改的員工編號>: ";
cin>>cNum;
int MN;
MN = Employee::MaxNum();
for(int i=0;i<MN;i++) //遍歷數據文件,查找要刪除的員工
{
if(Enum[i] == cNum)
Employee::shownum(cNum);
}
cout<<"確認要刪除該員工信息?(Y為確認 N為放棄): ";
cin>>tmp;
if(tmp=='Y')
{
if(i==MN-1)
dbo.WriteIn(-1);
else
{
for(int j=i;j<MN-1;j++)
{ Enum[j] = Enum[j+1]; }
dbo.WriteIn(-1);
}
cout<<" 刪除操作成功 ! "<<endl;
}
}
float Employee::Pay(int Employeeposition) //根據員工職位計算工資的函數
{
float tmpPay;
tmpPay = Employee::EmployeeBasePay + Employee::Employeeposition * Employee::EmployeeBasePay;
return tmpPay;
}
void DBOperate::WriteIn(int iflag) //數據操作函數 寫入
{
DBOperate::RefreshMaxNum(iflag);
ofstream myf("Employee.txt");
Employee e;
int MN;
MN = e.MaxNum();
for(int i=0;i<MN;i++)
{
myf<<Enum[i]<<'\n'<<Ename[i]<<'\n'<<Esex[i]<<'\n'<<Eage[i]<<'\n'<<Emarriage[i]<<'\n'<<Edegree[i]<<'\n'<<Edepart[i]<<'\n'<<Eposition[i]<<'\n'<<Eworktime[i]<<'\n'<<Epay[i]<<'\n';
}
myf.close();
return;
}
void DBOperate::ReadOut() //數據操作函數 讀出
{
ifstream myf("Employee.txt");
Employee e;
int MN;
MN = e.MaxNum();
for(int i=0 ;i<MN;i++)
{
myf>>DBOperate::Employeenum>>DBOperate::Employeename>>DBOperate::Employeesex>>DBOperate::Employeeage>>DBOperate::Employeemarriage
>>DBOperate::Employeedegree>>DBOperate::Employeedepart>>DBOperate::Employeeposition>>DBOperate::Employeeworktime>>DBOperate::Employeepay;
Enum[i] = DBOperate::Employeenum;
Ename[i] = DBOperate::Employeename;
Esex[i] = DBOperate::Employeesex;
Eage[i] = DBOperate::Employeeage;
Emarriage[i] = DBOperate::Employeemarriage;
Edegree[i] = DBOperate::Employeedegree;
Edepart[i] = DBOperate::Employeedepart;
Eposition[i] = DBOperate::Employeeposition;
Eworktime[i] = DBOperate::Employeeworktime;
Epay[i] = DBOperate::Employeepay;
}
myf.close();
}
void DBOperate::RefreshMaxNum(int iflag) //更新系統中員工計數文件的函數
{
int MaxNum = 0;
ifstream myif("EmployeeMaxNum.txt");
myif>>MaxNum;
myif.close();
MaxNum = MaxNum+iflag;
ofstream myof("EmployeeMaxNum.txt");
myof<<MaxNum;
myof.close();
}
int main() //主函數
{
system("color 06f"); //設置當前窗口的背景色和前景色 0 = 黑色 8 = 灰色
// 1 = 藍色 9 = 淡藍色
// 2 = 綠色 A = 淡綠色
// 3 = 淺綠色 B = 淡淺綠色
// 4 = 紅色 C = 淡紅色
// 5 = 紫色 D = 淡紫色
// 6 = 黃色 E = 淡黃色
// 7 = 白色 F = 亮白色
int select = 0;
while(select!=5)
{
cout<<" ╭————————————《主菜單》———————————╮"<<endl;
cout<<" ∣ 請選擇功能 ∣"<<endl;
cout<<" ├————————————————————————————┤"<<endl;
cout<<" ∣ 1.新建並輸入職工數據 ∣"<<endl;
cout<<" ∣ 2.按條件輸出職工數據 ∣"<<endl;
cout<<" ∣ 3.修改指定職工的數據 ∣"<<endl;
cout<<" ∣ 4.刪除數據 ∣"<<endl;
cout<<" ∣ 5.退出 ∣"<<endl;
cout<<" ╰————————————————————————————╯"<<endl;
cout<<" ——————————————————————————————"<<endl;
cout<<" 請選擇您要服務的類別: " ;
cin>>select;
Employee e;
DBOperate dbo;
switch(select)
{
case 1:
e.NewInfo(); break;
case 2:
dbo.ReadOut();
e.ShowInfo(); break;
case 3:
e.RefreshInfo(); break;
case 4:
e.DeleteInfo(); break;
case 5: break;
default:
cout<<"命令錯誤!"<<endl;
}
if(select == 5)
break;
}
exit(1);
return 0;
}
㈤ 用C語言設計職工信息管理系統
#include<iostream>
#include<string>
#include<fstream>
usingnamespacestd;
constn=50;//定義系統可錄入的員工最大數值
stringename[n];
longenum[n];
charesex[n];
inteage[n];
charemarriage[n];
intedepart[n];
inteposition[n];
intedegree[50];
inteworktime[n];
floatepay[n];
classemployee
{
public:
stringemployeename;
longemployeenum;
charemployeesex;
intemployeeage;
charemployeemarriage;
intemployeedepart;
intemployeeposition;
intemployeedegree;
intemployeeworktime;
floatemployeepay;
staticlongemployeemaxnum;
staticfloatemployeebasepay;
voidnewinfo();
voidshowinfo();
voidshowall();
voidshowdepart(intdepart);
voidshowdegree(intdegree);
voidshowage(intmin,intmax);
voidshownum(longnumber);
voidrefreshinfo();
voiddeleteinfo();
floatpay(intemployeegrade);
staticintmaxnum();
};
classdboperate
{
public:
stringemployeename;
longemployeenum;
charemployeesex;
intemployeeage;
charemployeemarriage;
intemployeedepart;
intemployeeposition;
intemployeedegree;
intemployeeworktime;
floatemployeepay;
staticlongemployeemaxnum;
staticfloatemployeebasepay;
voidwritein(intiflag);
voidreadout();
voidrefreshmaxnum(intiflag);//i=1or-1or0
};
longemployee::employeemaxnum=1000;
floatemployee::employeebasepay=1500;
intemployee::maxnum()//返回系統已經存儲的人數
{
intmn=0;
ifstreammyf;
myf.open("employeemaxnum.txt");
myf>>mn;
cout<<mn<<endl;
myf.close();
returnmn;
}
voidemployee::newinfo()//添加新成員函數
{
cout<<"新員工姓名:";
cin>>employee::employeename;
employee::employeenum=employeemaxnum+employee::maxnum()+1;
cout<<"新員工性別(f為女性,m為男性):";
cin>>employee::employeesex;
cout<<"新員工年齡:";
cin>>employee::employeeage;
cout<<"新員工婚姻狀況(y為已婚,n為未婚):";
cin>>employee::employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號:"<<endl;
cout<<"[1:初中2:高中3:本科4:碩士5:博士]";
cin>>employee::employeedegree;
while(employee::employeedegree!=1&&employee::employeedegree!=2&&employee::employeedegree!=3&&employee::employeedegree!=4&&employee::employeedegree!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<"[1:初中2:高中3:本科4:碩士5:博士]";
cin>>employee::employeedegree;
}
cout<<"新員工所在部門,請輸入相應部門的序號:"<<endl;
cout<<"[1:董事會2:市場部3:公關部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
while(employee::employeedepart!=1&&employee::employeedepart!=2&&employee::employeedepart!=3&&employee::employeedepart!=4&&employee::employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<"[1:董事會2:市場部3:公關部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
}
cout<<"新員工職位,請輸入相應職位的序號:"<<endl;
cout<<"[1:臨時職員2:正式職員3:主任4:部門經理5:董事長]";
cin>>employee::employeeposition;
while(employee::employeeposition!=1&&employee::employeeposition!=2&&employee::employeeposition!=3&&employee::employeeposition!=4&&employee::employeeposition!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<"[1:臨時職員2:正式職員3:主任4:部門經理5:董事長]";
cin>>employee::employeeposition;
}
cout<<"新員工的工作時(不需要輸入單位):";
cin>>employee::employeeworktime;
employee::employeepay=employee::pay(employee::employeeposition);
dboperatedbo;
dbo.readout();
intmaxnum=employee::maxnum();
enum[maxnum]=employee::employeenum;
ename[maxnum]=employee::employeename;
esex[maxnum]=employee::employeesex;
eage[maxnum]=employee::employeeage;
emarriage[maxnum]=employee::employeemarriage;
edegree[maxnum]=employee::employeedegree;
edepart[maxnum]=employee::employeedepart;
eposition[maxnum]=employee::employeeposition;
eworktime[maxnum]=employee::employeeworktime;
epay[maxnum]=employee::employeepay;
dbo.writein(1);
cout<<"添加新成員成功!"<<endl;
return;
}
voidemployee::showinfo()//程序主體數據輸出函數
{
intchoice1,choice2,min,max;
longsearchnum;
employeee;
cout<<"請選擇查詢方式:"<<endl;
cout<<"******************************************"<<endl;
cout<<"*輸出全體職工信息---------------------1"<<endl;
cout<<"*按職工部門輸出-----------------------2"<<endl;
cout<<"*按職工學歷輸出-----------------------3"<<endl;
cout<<"*按職工年齡輸出-----------------------4"<<endl;
cout<<"*按職工編號輸出-----------------------5"<<endl;
cout<<"******************************************"<<endl;
cin>>choice1;
switch(choice1)
{
case1:showall();break;
case2:cout<<"請輸入要查詢職工的部門編號:[1:董事會2:市場部3:公關部4:客服中心5:信息中心]";
cin>>choice2;
e.showdepart(choice2);break;
case3:cout<<"請輸入要查詢職工的學歷編號:[1:初中2:高中3:本科4:碩士5:博士]";
cin>>choice2;
e.showdegree(choice2);break;
case4:cout<<"請輸入要查詢的年齡范圍:";
cout<<"最小值:";
cin>>min;
cout<<"最大值:";
cin>>max;
e.showage(min,max);break;
case5:cout<<"請輸入要查詢的員工號:";
cin>>searchnum;
e.shownum(searchnum);break;
default:cout<<"出錯啦!"<<endl;break;
}
}
voidemployee::showall()//全體員工輸出函數
{inti;<br>longnumber;<br>for(i=0;i<employee::maxnum();i++)<br>{<br>number=enum[i];<br>shownum(number);<br>}
}
voidemployee::showdepart(intdepart)//按員工所在部門輸出函數
{
inti;
switch(depart)
{
case1:cout<<"董事會的成員有:>"<<endl;break;
case2:cout<<"市場部的成員有:>"<<endl;break;
case3:cout<<"公關部的成員有:>"<<endl;break;
case4:cout<<"客服中心成員有:>"<<endl;break;
case5:cout<<"信息中心成員有:>"<<endl;break;
default:cout<<"輸入錯誤!>"<<endl;break;
}
for(i=0;i<employee::maxnum();i++)
{
if(edepart[i]==depart)
{
longnumber=enum[i];
shownum(number);
}elsecontinue;
}
}
voidemployee::showdegree(intdegree)//按員工學歷輸出函數
{
inti;
switch(degree)
{
case1:cout<<"初中學歷的員工有:"<<endl;break;
case2:cout<<"高中學歷的員工有:"<<endl;break;
case3:cout<<"本科學歷的員工有:"<<endl;break;
case4:cout<<"碩士學位的員工有:"<<endl;break;
case5:cout<<"博士學位的員工有:"<<endl;break;
}
for(i=0;i<employee::maxnum();i++)
{
if(edegree[i]==degree)
{
longnumber=enum[i];
shownum(number);
}elsecontinue;
}
}
voidemployee::showage(intmin,intmax)//按員工年齡段輸出函數
{
inti;
for(i=0;i<employee::maxnum();i++)
{
if(eage[i]>=min&&eage[i]<=max)
{
longnumber=enum[i];
shownum(number);
}
elsecontinue;
}
}
voidemployee::shownum(longnumber)//按員工編號輸出函數
{
inti;
for(i=0;i<employee::maxnum();i++)
{
if(enum[i]==number)
{
cout<<"**********************************"<<endl;
cout<<"員工編號>"<<enum[i]<<endl;
cout<<"姓名>"<<ename[i]<<endl;
cout<<"性別>";
if(esex[i]=='f')cout<<"女"<<endl;
elseif(esex[i]=='m')cout<<"男"<<endl;
cout<<"年齡>"<<eage[i]<<"歲"<<endl;
cout<<"婚姻情況>";
if(emarriage[i]=='y')cout<<"已婚"<<endl;
elseif(emarriage[i]=='n')cout<<"未婚"<<endl;
cout<<"學歷>";
switch(edegree[i])
{
case1:cout<<"初中"<<endl;break;
case2:cout<<"高中"<<endl;break;
case3:cout<<"本科"<<endl;break;
case4:cout<<"碩士"<<endl;break;
case5:cout<<"博士"<<endl;break;
}
cout<<"所在部門>";
switch(edepart[i])
{
case1:cout<<"董事會"<<endl;break;
case2:cout<<"市場部"<<endl;break;
case3:cout<<"公關部"<<endl;break;
case4:cout<<"客服中心"<<endl;break;
case5:cout<<"信息中心"<<endl;break;
}
cout<<"所任職務>";
switch(eposition[i])
{
case1:cout<<"臨時成員"<<endl;break;
case2:cout<<"正式員工"<<endl;break;
case3:cout<<"主任"<<endl;break;
case4:cout<<"部門經理"<<endl;break;
case5:cout<<"董事長"<<endl;break;
}
cout<<"工作時長>"<<eworktime[i]<<"小時"<<endl;
cout<<"額定工資>"<<epay[i]<<"元"<<endl;
cout<<"**********************************"<<endl;
}
elsecontinue;
}
}
voidemployee::refreshinfo()//修改員工信息的函數
{
intcnum=1000;
dboperatedbo;
dbo.readout();
voidemployee::shownum(longnumber);
cout<<"請輸入您要修改的員工編號:>";
cin>>cnum;
intmn;
mn=employee::maxnum();
for(inti=0;i<mn;i++)//遍歷數據文件,查找要修改的員工數據
{
if(enum[i]==cnum)
{
employee::shownum(cnum);
cout<<"請輸入該員工的新信息:"<<endl;
cout<<"新員工姓名:";//錄入員工的新的數據,員工號保持不變
cin>>employee::employeename;
ename[i]=employee::employeename;
cout<<"新員工性別:[f為女性,m為男性]:";
cin>>employee::employeesex;
esex[i]=employee::employeesex;
cout<<"新員工年齡:";
cin>>employee::employeeage;
eage[i]=employee::employeeage;
cout<<"新員工婚姻狀況(y為已婚,n為未婚):";
cin>>employee::employeemarriage;
emarriage[i]=employee::employeemarriage;
cout<<"新員工學歷,請輸入相應學歷的序號:"<<endl;
cout<<"[1:初中2:高中3:本科4:碩士5:博士]";
cin>>employee::employeedegree;
while(employee::employeedegree!=1&&employee::employeedegree!=2&&employee::employeedegree!=3&&employee::employeedegree!=4&&employee::employeedegree!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<"[1:初中2:高中3:本科4:碩士5:博士]";
cin>>employee::employeedegree;
}
edegree[i]=employee::employeedegree;
cout<<"新員工所在部門,請輸入相應部門的序號:"<<endl;
cout<<"[1:董事會2:市場部3:公關部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
while(employee::employeedepart!=1&&employee::employeedepart!=2&&employee::employeedepart!=3&&employee::employeedepart!=4&&employee::employeedepart!=5)
{
cout<<"輸入有誤,請重新輸入:"<<endl;
cout<<"[1:董事會2:市場部3:公關部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
}
edepart[i]=employee::employeedepart;
cout<<"新員工職位,請輸入相應職位的序號:"<<endl;
cout<<"[1:臨時職員2:正式職員3:主任4:部門經理5:董事長]";
cin>>employee::employeeposition;
while(employee::employeeposition!=1&&employee::employeeposition!=2&&employee::employeeposition!=3&&employee::employeeposition!=4&&employee::employeeposition!=5)
{
cout<<"輸入有誤,請重新輸
㈥ 用c語言做一個:「職工信息管理系統設計」(謝謝了)
如果我在家,就給發給你一個。。。可是……網上很多,就不獻丑了。。。。
㈦ 用C語言設計並實現一個員工信息管理系統
#include<iostream>
#include<cstring>
usingnamespacestd;
typedefstructwage{
charunit[8];
charname[10];
charsex[4];
charbirthdate[12];
chartitle[20];
doublebasewage;
doublesubsidy;
doubletax;
doubleexpenses;
doubleresialwage;
}WAGE;
voidComputerResialwage(WAGEa[],intn){
for(inti=0;i<n;++i)
a[i].resialwage=a[i].basewage+a[i].subsidy-a[i].tax-a[i].expenses;
}
voidPrintTitle(void){
cout<<"單位姓名性別出生年月職稱基本工資津貼個稅水電費實發工資 ";
for(inti=0;i<79;++i)cout<<"*";cout<<endl;
}
voidRowShow(WAGEa[],inti){
cout<<a[i].unit<<"";
if(strlen(a[i].name)==4){
a[i].name[6]=a[i].name[4];
a[i].name[5]=a[i].name[3];
a[i].name[4]=a[i].name[2];
a[i].name[2]=a[i].name[3]='';
}
cout<<a[i].name<<""<<a[i].sex<<""<<a[i].birthdate;
if(strlen(a[i].title)==4){
a[i].title[6]=a[i].title[4];
a[i].title[5]=a[i].title[3];
a[i].title[4]=a[i].title[2];
a[i].title[2]=a[i].title[3]='';
}
cout<<""<<a[i].title<<"";
cout.precision(2);
cout.width(8);
cout<<fixed<<a[i].basewage<<"";cout.width(6);
cout<<fixed<<a[i].subsidy<<"";
cout.width(8);
cout<<fixed<<a[i].tax<<"";
cout.width(6);
cout<<fixed<<a[i].expenses<<"";
cout.width(8);
cout<<fixed<<a[i].resialwage<<endl;
}
voidShow(WAGEa[],intn){
for(inti=0;i<n;++i)RowShow(a,i);
}
voidSearch1(WAGEa[],intn){
inti,flag=1;
for(i=0;i<n;++i){
if(strcmp(a[i].unit,"理學院")==0&&a[i].basewage>900.00&&
strcmp(a[i].title,"副教授")==0&&strcmp(a[i].sex,"男")==0){
RowShow(a,i);
flag=0;
}
}
if(flag)cout<<"(沒找到符合條件者) ";
}
voidSearch2(WAGEa[],intn){
inti,flag=1;
for(i=0;i<n;++i){
if(strcmp(a[i].unit,"理學院")==0&&a[i].basewage<1200.00&&
strcmp(a[i].title,"教授")==0&&strcmp(a[i].sex,"男")==0){
RowShow(a,i);
flag=0;
}
}
if(flag)cout<<"(沒找到符合條件者) ";
}
intmain(){
WAGEa[]={
{"理學院","趙志軍","男","1957-06-25","教授",1150,411,176.6,90},
{"商學院","於銘","女","1979-10-21","助教",500,471,208.9,91},
{"工學院","許炎鋒","女","1954-03-08","教授",1250,630,306.2,96},
{"理學院","王嘉","女","1971-06-06","講師",850,475,100.3,89},
{"工學院","李新江","男","1962-10-02","教授",950,399,49.5,87},
{"商學院","郭海英","女","1963-02-07","副教授",950,332,77.6,85},
{"工學院","馬淑恩","女","1960-06-09","副教授",900,791,60.5,45},
{"理學院","王金科","男","1956-09-10","教授",1050,480,325.6,93},
{"理學院","李東慧","女","1950-08-07","教授",1350,364,52.3,94},
{"工學院","張寧","女","1980-01-01","助教",500,395,78,89},
{"商學院","王孟","男","1966-09-08","講師",800,463,220.3,98},
{"工學院","馬會爽","女","1970-02-09","講師",800,368,101.1,69},
{"工學院","史曉贇","女","1952-06-06","教授",1200,539,520.3,50},
{"理學院","劉燕鳳","女","1959-08-07","教授",1200,892,180.9,86},
{"工學院","齊飛","男","1961-04-05","副教授",1200,626,245.6,74},
{"商學院","張娟","女","1975-09-25","助教",650,374,625.3,86},
{"理學院","潘成文","男","1965-10-09","講師",950,402,1050,90},
{"工學院","邢易","女","1981-02-25","助教",600,325,300,90},
{"商學院","謝梟豪","女","1950-11-18","教授",1350,516,200,90},
{"工學院","胡洪靜","女","1952-06-24","教授",1350,277,100,86},
{"工學院","李雲飛","男","1969-05-04","講師",960,729,56,89},
{"商學院","張奇","女","1970-05-28","講師",960,331,69,89},
{"理學院","夏小波","女","1968-08-01","講師",960,482,89,45},
{"工學院","王瑋","女","1972-11-05","講師",960,340,98,79},
{"理學院","張帝","女","1950-03-26","教授",1300,335,124,90},
{"商學院","孫帥","男","1966-05-24","講師",900,748,326,79},
{"工學院","卜輝娟","女","1960-05-23","教授",960,481,651,78},
{"工學院","李輝玲","女","1978-09-09","助教",630,379,400,77},
{"理學院","劉亞靜","男","1969-08-09","副教授",890,377,23,66},
{"工學院","尹嫻","女","1958-06-09","教授",1050,955,59,65},
{"商學院","馬春英","男","1964-12-06","講師",850,387,78,69},
{"工學院","孟夢","女","1965-08-09","副教授",850,753,485.6,93},
{"工學院","梁曉萌","女","1975-06-09","助教",650,551,136.5,99},
{"理學院","張然","女","1973-03-03","講師",800,761,203.1,100},
{"工學院","彭雁南","男","1978-05-09","助教",650,200,200,90}
};
inti,n=sizeof(a)/sizeof(a[0]);
if(n==0)return1;
ComputerResialwage(a,n);
PrintTitle();
for(i=0;i<n;++i)RowShow(a,i);
for(i=0;i<79;++i)cout<<"*";
cout<<endl;cout<<" 理學院,基本工資高於900元的男副教授有: ";
PrintTitle();
Search1(a,n);
for(i=0;i<79;++i)cout<<"*";
cout<<endl;
cout<<" 理學院,基本工資低於1200元的男教授有: ";
PrintTitle();
Search2(a,n);
for(i=0;i<79;++i)cout<<"*";
cout<<endl<<endl;
return0;
}
㈧ C語言程序設計——職工信息管理系統(急)
㈨ C語言職工信息管理系統設計
以下是我的程序,剛編好的,剛好符合你的要求,看看吧,對你應該有幫助:
呵呵
#include <stdio.h>
#include <windows.h>
#include <time.h>
#include <string.h>
#define N 100
struct employee
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
}em[100]; /*定義一個結構體*/
void menu();
void input();
void save(int);
void display();
void del();
void add();
void search();
void search_num();
void search_xueli();
void search_tel();
void modify(); /*定義各函數*/
void menu() /*菜單函數*/
{
printf(" ☆☆☆計算機科學與技術學系☆☆☆\n");
printf("\n");
printf(" ∮08802班 關麗霞∮\n");
printf("\n");
printf(" ******************職工信息管理****************\n");
printf(" 1.錄入職工信息");
printf(" 2.瀏覽職工信息\n");
printf(" 3.查詢職工信息");
printf(" 4.刪除職工信息\n");
printf(" 5.添加職工信息");
printf(" 6.修改職工信息\n");
printf(" 7.退出\n");
printf(" ********************謝謝使用******************\n");
printf("\n");
printf("\n");
}
void main()
{
menu(); /*調用菜單函數*/
int n,flag;
char a;
do
{
printf("請選擇你需要操作的步驟(1--7):\n");
scanf("%d",&n);
if(n>=1&&n<=7)
{
flag=1;
break;
}
else
{
flag=0;
printf("您輸入有誤,請重新選擇!");
}
}
while(flag==0);
while(flag==1)
{
switch(n)
{
case 1:printf(" ◆◆◆輸入職工信息◆◆◆\n");printf("\n");input();break;
case 2:printf(" ◆◆◆瀏覽職工信息◆◆◆\n");printf("\n");display();break;
case 3:printf(" ◆◆◆按職工號查詢職工信息◆◆◆\n");printf("\n");search();break;
case 4:printf(" ◆◆◆刪除職工信息◆◆◆\n");printf("\n");del();break;
case 5:printf(" ◆◆◆添加職工信息◆◆◆\n");printf("\n");add();break;
case 6:printf(" ◆◆◆修改職工信息◆◆◆\n");printf("\n");modify();break;
case 7:exit(0);break;
default :break;
}
getchar();
printf("\n");
printf("是否繼續進行(y or n):\n");
scanf("%c",&a);
if(a=='y')
{
flag=1;
system("cls"); /*清屏*/
menu(); /*調用菜單函數*/
printf("請再次選擇你需要操作的步驟(1--6):\n");
scanf("%d",&n);
printf("\n");
}
else
exit(0);
}
}
void input() /*錄入函數*/
{
int i,m;
printf("請輸入需要創建信息的職工人數(1--100):\n");
scanf("%d",&m);
for (i=0;i<m;i++)
{
printf("職工號: ");
srand((int)time(0));
em[i].num=rand()%10000+20000000;
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf("請輸入姓名: ");
scanf("%s",em[i].name);
getchar();
printf("請輸入性別(f--女 m--男): ");
scanf("%c",&em[i].sex);
printf("請輸入年齡: ");
scanf("%d",&em[i].age);
printf("請輸入學歷: ");
scanf("%s",em[i].xueli);
printf("請輸入工資: ");
scanf("%d",&em[i].wage);
printf("請輸入住址: ");
scanf("%s",em[i].addr);
printf("請輸入電話: ");
scanf("%d",&em[i].tel);
printf("\n");
}
printf("\n創建完畢!\n");
save(m);
}
void save(int m) /*保存文件函數*/
{
int i;
FILE*fp;
if ((fp=fopen("employee_list","wb"))==NULL) /*創建文件並判斷是否能打開*/
{
printf ("cannot open file\n");
exit(0);
}
for (i=0;i<m;i++) /*將內存中職工的信息輸出到磁碟文件中去*/
if (fwrite(&em[i],sizeof(struct employee),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}
int load() /*導入函數*/
{
FILE*fp;
int i=0;
if((fp=fopen("employee_list","rb"))==NULL)
{
printf ("cannot open file\n");
exit(0);
}
else
{
do
{
fread(&em[i],sizeof(struct employee),1,fp);
i++;
}
while(feof(fp)==0);
}
fclose(fp);
return(i-1);
}
void display() /*瀏覽函數*/
{
int i;
int m=load();
printf("\n 職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
for(i=0;i<m;i++) /*m為輸入部分的職工人數*/
printf("\n %d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
}
void del() /*刪除函數*/
{
int m=load();
int i,j,n,t,flag;
char name[20];
printf("\n 原來的職工信息:\n");
display(); /* 調用瀏覽函數*/
printf("\n");
printf("請輸入要刪除的職工的姓名:\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n已找到此人,原始記錄為:\n");
printf("\n職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n確實要刪除此人信息請按1,不刪除請按0\n");
scanf("%d",&n);
if(n==1) /*如果刪除,則其他的信息都往上移一行*/
{
for(j=i;j<m-1;j++)
{
strcpy(em[j].name,em[j+1].name);
em[j].num=em[j+1].num;
em[j].sex=em[j+1].sex;
em[j].age=em[j+1].age;
strcpy(em[j].xueli,em[j+1].xueli);
em[j].wage=em[j+1].wage;
strcpy(em[j].addr,em[j+1].addr);
em[j].tel=em[j+1].tel;
}
flag=0;
}
}
}
if(!flag)
m=m-1;
else
printf("\n對不起,查無此人!\n");
printf("\n 瀏覽刪除後的所有職工信息:\n");
save(m); /*調用保存函數*/
display(); /*調用瀏覽函數*/
printf("\n繼續刪除請按1,不再刪除請按0\n");
scanf("%d",&t);
switch(t)
{
case 1:del();break;
case 0:break;
default :break;
}
}
void add()/*添加函數*/
{
FILE*fp;
int n;
int count=0;
int i;
int m=load();
printf("\n 原來的職工信息:\n");
display(); /* 調用瀏覽函數*/
printf("\n");
fp=fopen("emploee_list","a");
printf("請輸入想增加的職工數:\n");
scanf("%d",&n);
for (i=m;i<(m+n);i++)
{
printf("\n 請輸入新增加職工的信息:\n");
printf("請輸入職工號: ");
srand((int)time(0));
em[i].num=rand()%10000+20000000;
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf("請輸入姓名: ");
scanf("%s",em[i].name);
getchar();
printf("請輸入性別(f--女 m--男): ");
scanf("%c",&em[i].sex);
printf("請輸入年齡: ");
scanf("%d",&em[i].age);
printf("請輸入學歷: ");
scanf("%s",em[i].xueli);
printf("請輸入工資: ");
scanf("%d",&em[i].wage);
printf("請輸入住址: ");
scanf("%s",em[i].addr);
printf("請輸入電話: ");
scanf("%d",&em[i].tel);
printf("\n");
count=count+1;
printf("已增加的人數:\n");
printf("%d\n",count);
}
printf("\n添加完畢!\n");
m=m+count;
printf("\n瀏覽增加後的所有職工信息:\n");
printf("\n");
save(m);
display();
fclose(fp);
}
void search()/*查詢函數*/
{
int t,flag;
do
{
printf("\n按職工號查詢請按1 ; 按學歷查詢請按2 ; 按電話號碼查詢請按3,進入主函數按4\n");
scanf("%d",&t);
if(t>=1&&t<=4)
{
flag=1;
break;
}
else
{
flag=0;
printf("您輸入有誤,請重新選擇!");
}
}
while(flag==0);
while(flag==1)
{
switch(t)
{
case 1:printf("按職工號查詢\n");search_num();break;
case 2:printf("按學歷查詢\n");search_xueli();break;
case 3:printf("按電話號碼查詢\n");search_tel();break;
case 4:main();break;
default:break;
}
}
}
void search_num()
{
int num;
int i,t;
int m=load();
printf("請輸入要查找的職工號(20001111---20009999):\n");
scanf("%d",&num);
for(i=0;i<m;i++)
if(num==em[i].num)
{
printf("\n已找到此人,其記錄為:\n");
printf("\n職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n對不起,查無此人\n");
printf("\n");
printf("返回查詢函數請按1,繼續查詢職工號請按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2: break;
default:break;
}
}
void search_xueli()
{
char xueli[30];
int i,t;
int m=load();
printf("請輸入要查找的學歷:\n");
scanf("%s",xueli);
for(i=0;i<m;i++)
if(strcmp(em[i].xueli,xueli)==0)
{
printf("\n已找到,其記錄為:\n");
printf("\n職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
}
if(i==m)
printf("\n對不起,查無此人\n");
printf("\n");
printf("返回查詢函數請按1,繼續查詢學歷請按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}
}
void search_tel()
{
long int tel;
int i, t;
int m=load();
printf("請輸入要查找的電話號碼:\n");
scanf("%ld",&tel);
for(i=0;i<m;i++)
if(tel==em[i].tel)
{
printf("\n已找到此人,其記錄為:\n");
printf("\n職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n對不起,查無此人\n");
printf("\n");
printf("返回查詢函數請按1,繼續查詢電話號碼請按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}
}
void modify() /*修改函數*/
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
int b,c,i,n,t,flag;
int m=load(); /*導入文件內的信息*/
printf("\n 原來的職工信息:\n");
display(); /* 調用瀏覽函數*/
printf("\n");
printf("請輸入要修改的職工的姓名:\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n已找到此人,原始記錄為:\n");
printf("\n職工號\t姓名\t性別\t年齡\t學歷\t工資\t住址\t電話 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n確實要修改此人信息請按1 ; 不修改請按0\n");
scanf("%d",&n);
if(n==1)
{
printf("\n需要進行修改的選項\n 1.職工號 2.姓名 3.性別 4.年齡 5.學歷 6.工資 7.住址 8.電話\n");
printf("請輸入你想修改的那一項序號:\n");
scanf("%d",&c);
if(c>8||c<1)
printf("\n選擇錯誤,請重新選擇!\n");
}
flag=0;
}
}
if(flag==1)
printf("\n對不起,查無此人!\n");
do
{
switch(c) /*因為當找到第i個職工時,for語句後i自加了1,所以下面的應該把改後的信息賦值給第i-1個人*/
{
case 1:printf("職工號改為: ");
scanf("%d",&num);
em[i-1].num=num;
break;
case 2:printf("姓名改為: ");
scanf("%s",name);
strcpy(em[i-1].name,name);
break;
case 3:printf("性別改為: ");
getchar();
scanf("%c",&sex);
em[i-1].sex=sex;
break;
case 4:printf("年齡改為: ");
scanf("%d",&age);
em[i-1].age=age;
break;
case 5:printf("學歷改為: ");
scanf("%s",xueli);
strcpy(em[i-1].xueli,xueli);
break;
case 6:printf("工資改為: ");
scanf("%d",wage);
break;
case 7:printf("住址改為: ");
scanf("%s",addr);
strcpy(em[i-1].addr,addr);
break;
case 8:printf("電話改為: ");
scanf("%ld",&tel);
em[i-1].tel=tel;
break;
}
printf("\n");
printf("\n是否確定所修改的信息?\n 是 請按1 ; 不,重新修改 請按2: \n");
scanf("%d",&b);
}
while(b==2);
printf("\n瀏覽修改後的所有職工信息:\n");
printf("\n");
save(m);
display();
printf("\n繼續修改請按1,不再修改請按0\n");
scanf("%d",&t);
switch(t)
{
case 1:modify();break;
case 0:break;
default :break;
}
}
㈩ C語言課程設計 職工信息管理系統
/*
Microsoft Visual C++ .NET編譯通過
by 做他@07.12.29
*/
#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 line
cout<<"請選擇操作: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;
}
}
滿意請採納。