當前位置:首頁 » 編程語言 » 簡單的c語言系統設計

簡單的c語言系統設計

發布時間: 2025-03-06 08:21:17

① 用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 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;
}
}

③ 用C語言設計一個學生信息查詢系統程序

1、首先創建一個c語言項目。然後右鍵頭文件,創建一個Stu的頭文件。

熱點內容
ES開腳本 發布:2025-03-06 15:12:15 瀏覽:532
直播伺服器怎麼連接電腦 發布:2025-03-06 15:09:56 瀏覽:663
如何更改admini密碼 發布:2025-03-06 15:09:54 瀏覽:670
androidndk配置環境變數 發布:2025-03-06 15:08:24 瀏覽:471
oppor9應用加密在哪 發布:2025-03-06 15:02:06 瀏覽:855
ehome平台伺服器ip 發布:2025-03-06 14:43:22 瀏覽:986
win8取消賬戶登錄密碼怎麼設置 發布:2025-03-06 14:43:15 瀏覽:434
如何看電腦配置系統 發布:2025-03-06 14:41:09 瀏覽:470
劍網3為什麼總顯示伺服器繁忙 發布:2025-03-06 14:26:23 瀏覽:641
冒險島手游公會戰腳本 發布:2025-03-06 14:16:32 瀏覽:952