當前位置:首頁 » 編程語言 » c語言員工管理信息系統
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言員工管理信息系統

發布時間: 2023-04-22 06:31:58

⑴ C++寫的公司員工信息管理系統(可加分)

#include<iostream>
#include<string>
using namespace std;
class employee
{
public:
string name;
string sex;
string techang;
string xuexing;
string xingzuo;
string attend;
string getin;
string birthday;
int static number;
int grade;
int money;
long call;
employee(){number++;grade=1;};
void virtual input(){};
void show()
{
cout<<"姓名:"<<name<<" ";
cout<<"性別:"<<sex<<" ";
cout<<"年月:"<<birthday<<" ";
cout<<"特長:"<<techang<<" ";
cout<<"血型:"<<xuexing<<" ";
cout<<"星座:"<<xingzuo<<" ";
cout<<"參加公司時間:"<<attend<<" ";
cout<<"進入公司時間:"<<getin<<" ";
cout<<"月薪:"<<money<<" ";
cout<<"編號:"<<number<<" ";
cout<<"級別:"<<grade<<" "<<endl;
};
};
int employee::number=0;
class technician:public employee
{
public:
technician(){money=3000;};
void input()
{
cout<<"姓名:";cin>>name;cout<<endl;
cout<<"性別:";cin>>sex;cout<<endl;
cout<<"年月:";cin>>birthday;cout<<endl;
cout<<"特長:";cin>>techang;cout<<endl;
cout<<"血型:";cin>>xuexing;cout<<endl;
cout<<"星座:";cin>>xingzuo;cout<<endl;
cout<<"參加公司時間:";cin>>attend;cout<<endl;
cout<<"進入公司時間:";cin>>getin;cout<<endl;
};

};
class manger:public employee
{
public:
int x;
void input()
{
int x;
cout<<"姓名:";cin>>name;cout<<endl;
cout<<"性別:";cin>>sex;cout<<endl;
cout<<"經理類型(1 總經理,2 銷售經理,3 技術經理):";cin>>x;
switch(x)
{
int y,z;
case 1:
money=10000;break;
case 2:
cout<<"銷售額:";cin>>y;money=4000+y/20;break;
case 3:
cout<<"獎金:";cin>>z;money=6000+z;break;
};
cout<<"年月:";cin>>birthday;cout<<endl;
cout<<"特長:";cin>>techang;cout<<endl;
cout<<"血型:";cin>>xuexing;cout<<endl;
cout<<"星座:";cin>>xingzuo;cout<<endl;
cout<<"參加公司時間:";cin>>attend;cout<<endl;
cout<<"進入公司時間:";cin>>getin;cout<<endl;
};
};
class saleman:public employee
{
public:
int m;
void input()
{
cout<<"姓名:";cin>>name;cout<<endl;
cout<<"性別:";cin>>sex;cout<<endl;
cout<<"年月:";cin>>birthday;cout<<endl;
cout<<"銷售額:";cin>>m;money=m;cout<<endl;
cout<<"特長:";cin>>techang;cout<<endl;
cout<<"血型:";cin>>xuexing;cout<<endl;
cout<<"星座:";cin>>xingzuo;cout<<endl;
cout<<"參加公司時間:";cin>>attend;cout<<endl;
cout<<"進入公司時間:";cin>>getin;cout<<endl;
};
};
void main()
{
int n;
manger a;
technician b;
saleman c;
cout<<"***通信09-3***孫太川***20092258****"<<endl;
cout<<"***********************************"<<endl;
cout<<"* 主菜單 *"<<endl;
cout<<"* 1 輸入職工信息 *"<<endl;
cout<<"* 2 查詢職工信息 *"<<endl;
cout<<"* 3 退出系統 *"<<endl;
cout<<"***********************************"<<endl;
while(1)
{
cout<<"選擇你所需要的菜單:";
cin>>n;
if(n==3)break;
switch(n)
{
int w;
case 1:
cout<<"選擇你所需要輸入的職工類型:"<<endl;
cout<<"(1 經理,2 技術人員,3 銷售人員):";
cin>>w;
switch(w)
{
case 1:
a.input();break;
case 2:
b.input();break;
case 3:
c.input();break;
};
case 2:
int u;
cout<<"編號:";cin>>u;
switch(u)
{
case 1:
a.show();break;
case 2:
b.show();break;
case 3:
c.show();break;
};
};
};
}

⑵ 職工信息管理系統.c語言

#include<string.h>
void menu()
{
int n,w1;
do
{
printf("\t\t************************************************\n\n");
printf("\t\t************************************************\n\n");

printf("\t\t *** choose function ************\n\n");
printf("\t\t *** 1 Enter new data ************\n\n");
printf("\t\t *** 2 Modify data ************\n\n");
printf("\t\t *** 3 Search by people.xueli and num*****\n\n");
printf("\t\t *** 4 Browse data ************\n\n");
printf("\t\t *** 5 add data ************\n\n");
printf("\t\t *** 6 Exit ************\n\n");
printf("\t\t************************************************\n\n");
printf("\t\t************************************************\n\n");
printf("Choose your number(1-6):[ ]\b\b");
scanf("%d",&n);
if(n<1||n>6)
w1=1;
else w1=0;
}
while(w1==1);
switch(n)
{
case 1:enter();break;
case 2:modify();break;
case 3:search();break;
case 4:browse();break;
case 5:add();break;
case 6:exit(0);
}
}

main()
{
system("cls");
menu();
}

#define N 100
struct people
{
char num[100];
char name[15];
char sex[20];
char age[20];
char xueli[20];
char gong[20];
char address[20];
char telephone[20];
}people[N];

# include <stdio.h>

enter()
{
int i,n;
printf("How many people(0-%d)?:",N-1);
scanf("%d",&n);
printf("\n Enter data now\n\n");
for(i=0;i<n;i++)
{
printf("\n Input %dth people record.\n",i+1);
input(i);
}
if(i!=0)save(n);
printf_back();
}

browse()
{
int i,j,n;
n=load();
printf_face();
for(i=0;i<n;i++)
{
if((i!=0)&&(i%10==0))
{
printf("\n\nPass any key to continue ....");
getch();
puts("\n\n");
}
printf_one(i) ;
}
printf("\tThere are %d record.\n",n);
printf("\nPass any key to back ...");
getch();
menu();
}

add()
{
int i,n,m,k;
FILE*fp;
n=load();
printf("How many people are you want to add(0-%d)?:",N-1-n);
scanf("%d",&m);
k=m+n;
for(i=n;i<k;i++)
{
printf("\nInput %dth people record.\n",i-n+1 );
input(i);
}
if((fp=fopen("Pro.txt","ab"))==NULL)
{
printf("cannot open file\n");
}
for(i=n;i<k;i++)
if(fwrite(&people[i],sizeof(struct people),1,fp)!=1)
printf("file write error\n");
fclose(fp);
printf_back();
}

search()
{
int i,n,k,w1=1,w2,w3,w4,m,a;
struct people p;
n=load();
do
{
printf("\n\nWhich way do you want to choose? \n\t1).By xueli 2).By num [ ]\b\b");
scanf("%d",&m);
switch(m)
{
case 1:
do
{ k=-1;
printf("\n\nEnter xeuli that you want to search! xueli.");
scanf("%s",p.xueli);
printf_face();
for(i=0;i<n;i++)
if(strcmp(p.xueli,people[i].xueli)==0)
{ k=i;
printf_one(k);break;
}
if(k==-1)
{ printf("\n\nNO exist!please");
printf("\n\nAre you again?\n\t1).again 2).NO and back [ ]\b\b");
scanf("%d",&w1);
if(w1==2)
printf_back();
}
}
while(k==-1&&w1==1);break;
case 2:
do
{k=-1;
printf("\n\nEnter num that you want to search! num.");
scanf("%s",p.num);
printf_face();
for(i=0;i<n;i++)
if(strcmp(p.num,people[i].num)==0)
{k=i;
printf_one(k);break;
}
if(k==-1)
{printf("\n\nNO exist!please");
printf("\n\nAre you again?\n\t1).again 2).NO and back [ ]\b\b");
scanf("%d",&w1);
if(w1==2)
printf_back();
}
}
while(k==-1&&w1==1);break;
}
w4=0;w3=0;
if(k!=-1)
{printf("\n\nWhat do you want to do?\n\t 1).Search 2).Modify 3).Delete 4).Back menu [ ]\b\b");
scanf("%d",&w2);
switch(w2)
{case 2:w3=modify_data(k,n);break;
case 3:{printf("\nAre you sure?\n\t 1).Sure 2).No and back [ ]\b\b");
scanf("%d",&w4);
if(w4==1)
for(a=k;a<n;a++)
{strcpy(people[a].num,people[a+1].num);
strcpy(people[a].name,people[a+1].name);
strcpy(people[a].sex,people[a+1].sex);
strcpy(people[a].age,people[a+1].age);
strcpy(people[a].xueli,people[a+1].xueli);
strcpy(people[a].gong,people[a+1].gong);
strcpy(people[a].address,people[a+1].address);
strcpy(people[a].telephone,people[a+1].telephone);

}

break;
}
}
if(w3==1||w4==1)
{save(n);
printf("\n\nSuccessful.^_^.");
printf("\n\nWhant do you want to do? \n\t 1).Search another 2).Back [ ]\b\b" );
scanf("%d",&w2);
}
}
}
while(w2==1);
menu();
}

modify()
{struct people p;
FILE *fp;
int i,n,k,w0=1,w1,w2=0;
n=load();
do
{
k=-1;
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nRemember NO.which needed modify.pass any key to contiune ...");
getch();
puts("\n\n");
}
printf_one(i);
}
do
{printf("\n\nEnter NO.that you want to modify! NO.:");
scanf("%s",p.num);
for(i=0;i<n;i++)
if(strcmp(p.num,people[i].num)==0)
{k=i;
p=people[i];
}
if(k==-1)printf("\n\nNO exist!please again");
}while(k==-1);
printf_face();
printf_one(k);
w1=modify_data(k,n);
if(w1==1)
{printf("\nSuccessful ^_^.\n\nAre you modify another ?\n\n\t 1).Yes 2).Back with save\t[ ]\b\b");
scanf("%d",&w0);
w2=1;
}
else
{w0=0;
if(w2==1)
people[k]=p;
}
if(w0!=1&&w2==1)
save(n);
}while(w0==1);
menu();
}

save(int n)
{FILE *fp;
int i;
if((fp=fopen("Pro.txt","wb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;i<n;i++)
if(people[i].num!=0)
if(fwrite(&people[i],sizeof(struct people),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

load()
{FILE *fp;
int i;
if((fp=fopen("Pro.txt","rb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;!feof(fp);i++)
fread(&people[i],sizeof(struct people),1,fp);
fclose(fp);
return(i-1);
}

input(int i)
{
no_input(i,i);
printf("num:");
scanf("%s",people[i].num);
printf("name:");
scanf("%s", people[i].name) ;
printf("sex:");
scanf("%s",people[i].sex);
printf("age:");
scanf("%s",people[i].age);
printf("xueli:");
scanf("%s",people[i].xueli);
printf("gong:");
scanf("%s",people[i].gong);
printf("address:");
scanf("%s",people[i].address);
printf("telephone:");
scanf("%s",people[i].telephone);
}

modify_data(int i)
{int c,w1;
do
{puts("\nmodify by=>\n\n 1).num 2).name 3).sex 4).ages 5).xueli 6)gong 7)address 8)telephone ");
printf("Which you needed?:[ ]\b\b");
scanf("%d",&c);
if(c>8||c<1)
{puts("\nChoice error!Please again!");
getchar();
}
}while(c>8||c<1);
do
{switch(c)
{
case 1:printf("num:");scanf("%s",people[i].num);break;
case 2:printf("name:");scanf("%s",people[i].name);break;
case 3:printf("sex:");scanf("%s",people[i].sex);break;
case 4:printf("age:");scanf("%s",people[i].age);break;
case 5:printf("xueli:");scanf("%s",people[i].xueli);break;
case 6:printf("gong:");scanf("%s",people[i].gong);break;
case 7:printf("address:");scanf("%s",people[i].address);break;
case 8:printf("telephone:");scanf("%s",people[i].telephone);break;
}
puts("\nNow:\n");
printf_face();
printf_one(i);
printf("\nAre you sure?\n\n\t 1).Sure 2).No and remodify 3).Back without save in this time [ ]\b\b");
scanf("%d",&w1);
}
while(w1==2);
return(w1);
}

no_input(int i,int n)
{int j,k,w1;
do
{w1=0;

for(j=0;people[i].num[j]!='\0';j++)
if(people[i].num[j]>'9')
{puts("Input error!Only be made up of(0-9).Please reinput!\n");
w1=1;break;
}
if(w1!=1)
for(k=0;k<n;k++)
if(k!=i&&strcmp(people[k].num,people[i].num)==0)
{puts("This record is exist.please reinput!\n");
}
}
while(w1==1);
}

printf_face()
{
printf("\nnum name sex ages xueli gong address telephone \n");
}

printf_one(int i)
{
int j;
printf("%7s%7s%7s%7s%7s%7s%10s%12s\n",people[i].num,people[i].name,people[i].sex,people[i].age,people
[i].xueli,people[i].gong,people[i].address,people[i].telephone);
}

printf_back()
{
int j,w;
printf("\n\n\tSuccessful.^_^\n\n");
printf("What do you want you to do?\n\n\t1).Browse all now\t2).Back: [ ]\b\b");
scanf("%d",&w);
if(w==1)
browse();
else menu();
}

⑶ 員工信息管理系統,C語言做

以下是我的程序,剛編好的,剛好符合你的要求,看看吧,對你應該有幫助:
呵呵
#include
#include
#include
#include
#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語言設計並實現一個員工信息管理系統

#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語言 職工信息管理系統

/*這是我開始做課程設計時寫的*/
#include "stdio.h" /*標准輸入輸出函數庫*/
#include "stdlib.h" /*標准函數庫*/
#include "string.h" /*字元串函數庫*/
#include "conio.h" /*屏幕操作函數庫*/
#define HEADER1 " -------------------------------ZGGZ---------------------------------------- \n"
#define HEADER2 "| number| name | jbgz | jj | kk | yfgz | sk | sfgz | \n"
#define HEADER3 "|--------|-----------|--------|--------|--------|--------|--------|--------| \n"
#define FORMAT "|%-8s|%-10s |%8.2f|%8.2f|%8.2f|%8.2f|%8.2f|%8.2f| \n"
#define DATA p->num,p->name,p->jbgz,p->jj,p->kk,p->yfgz,p->sk,p->sfgz
#define END "---------------------------------------------------------------------------- \n"
#define N 60
int saveflag=0; /*是否需要存檔的標志變數*/
/*定義與職工有關的數據結構*/
typedef struct employee /*標記為employee*/
{
char num[10]; /*職工編號*/
char name[15]; /*職工姓名*/
float jbgz; /*基本工資*/
float jj; /*獎金*/
float kk; /*扣款*/
float yfgz; /*應發工資*/
float sk; /*稅款*/
float sfgz; /*實發工資*/
}ZGGZ;

void menu() /*主菜單*/
{
system("cls"); /*調用DOS命令,清屏.與clrscr()功能相同*/
textcolor(10); /*在文本模式中選擇新的字元顏色*/
gotoxy(10,5); /*在文本窗口中設置游標*/
cprintf(" The Employee' Salary Management System \n");
gotoxy(10,8);
cprintf(" *************************Menu********************************\n");
gotoxy(10,9);
cprintf(" * 1 input record 2 delete record *\n");
gotoxy(10,10);
cprintf(" * 3 search record 4 modify record *\n");
gotoxy(10,11);
cprintf(" * 5 insert record 6 count record *\n");
gotoxy(10,12);
cprintf(" * 7 sort reord 8 save record *\n");
gotoxy(10,13);
cprintf(" * 9 display record 0 quit system *\n");
gotoxy(10,14);
cprintf(" *************************************************************\n");
/*cprintf()送格式化輸出至文本窗口屏幕中*/
}
void printheader() /*格式化輸出表頭*/
{
printf(HEADER1);
printf(HEADER2);
printf(HEADER3);
}
void printdata(ZGGZ pp) /*格式化輸出表中數據*/
{
ZGGZ* p;
p=&pp;
printf(FORMAT,DATA);

}

void Disp(ZGGZ tp[],int n) /*顯示數組tp[]中存儲的記錄,內容為employee結構中定義的內容*/
{
int i;
if(n==0) /*表示沒有職工工資記錄*/
{
printf("\n=====>Not employee record!\n");
getchar();
return;
}

printf("\n\n");
printheader(); /*輸出表格頭部*/
i=0;
while(i<n) /*逐條輸出數組中存儲的職工信息*/
{
printdata(tp[i]);
i++;
printf(HEADER3);
}
getchar();
}

void Wrong() /*輸出按鍵錯誤信息*/
{
printf("\n\n\n\n\n***********Error:input has wrong! press any key to continue**********\n");
getchar();
}

void Nofind() /*輸出未查找此職工的信息*/
{
printf("\n=====>Not find this employee record!\n");
}

/*************************************************************
作用:用於定位數組中符合要求的記錄,並返回保存該記錄的數組元素下標值
參數:findmess[]保存要查找的具體內容; nameornum[]保存按什麼在數組中查找;
**************************************************************/
int Locate(ZGGZ tp[],int n,char findmess[],char nameornum[])
{
int i=0;
if(strcmp(nameornum,"num")==0) /*按職工編號查詢*/
{
while(i<n)
{
if(strcmp(tp[i].num,findmess)==0) /*若找到findmess值的職工編號*/
return i;
i++;
}
}
else if(strcmp(nameornum,"name")==0) /*按職工姓名查詢*/
{
while(i<n)
{
if(strcmp(tp[i].name,findmess)==0) /*若找到findmess值的姓名*/
return i;
i++;
}
}
return -1; /*若未找到,返回一個整數-1*/
}

/*輸入字元串,並進行長度驗證(長度<lens)*/
void stringinput(char *t,int lens,char *notice)
{
char n[255];
do{
printf(notice); /*顯示提示信息*/
scanf("%s",n); /*輸入字元串*/
if(strlen(n)>lens) printf("\n exceed the required length! \n"); /*進行長度校驗,超過lens值重新輸入*/
}while(strlen(n)>lens);
strcpy(t,n); /*將輸入的字元串拷貝到字元串t中*/

}

/*輸入數值,0<=數值)*/
float numberinput(char *notice)
{
float t=0.00;
do{
printf(notice); /*顯示提示信息*/
scanf("%f",&t); /*輸入如工資等數值型的值*/
if(t<0) printf("\n score must >=0! \n"); /*進行數值校驗*/
}while(t<0);
return t;
}

/*增加職工工資記錄*/
int Add(ZGGZ tp[],int n)
{
char ch,num[10];
int i,flag=0;
system("cls");
Disp(tp,n); /*先列印出已有的職工工資信息*/

while(1) /*一次可輸入多條記錄,直至輸入職工編號為0的記錄才結束添加操作*/
{
while(1) /*輸入職工編號,保證該編號沒有被使用,若輸入編號為0,則退出添加記錄操作*/
{
stringinput(num,10,"input number(press '0'return menu):"); /*格式化輸入編號並檢驗*/
flag=0;
if(strcmp(num,"0")==0) /*輸入為0,則退出添加操作,返回主界面*/
{return n;}
i=0;
while(i<n) /*查詢該編號是否已經存在,若存在則要求重新輸入一個未被佔用的編號*/
{
if(strcmp(tp[i].num,num)==0)
{
flag=1;
break;
}
i++;
}

if(flag==1) /*提示用戶是否重新輸入*/
{ getchar();
printf("==>The number %s is existing,try again?(y/n):",num);
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
continue;
else
return n;
}
else
{break;}
}
strcpy(tp[n].num,num); /*將字元串num拷貝到tp[n].num中*/
stringinput(tp[n].name,15,"Name:");
tp[n].jbgz=numberinput("jbgz:"); /*輸入並檢驗基本工資*/
tp[n].jj=numberinput("jiangjin:"); /*輸入並檢驗獎金*/
tp[n].kk=numberinput("koukuan:"); /*輸入並檢驗扣款*/
tp[n].yfgz=tp[n].jbgz+tp[n].jj-tp[n].kk; /*計算應發工資*/
tp[n].sk=tp[n].yfgz*0.12; /*計算稅金,這里取應發工資的百分之一十二*/
tp[n].sfgz=tp[n].yfgz-tp[n].sk; /*計算實發工資*/
saveflag=1;
n++;
}
return n;
}

/*按職工編號或姓名,查詢記錄*/
void Qur(ZGGZ tp[],int n)
{
int select; /*1:按編號查,2:按姓名查,其他:返回主界面(菜單)*/
char searchinput[20]; /*保存用戶輸入的查詢內容*/
int p=0;
if(n<=0) /*若數組為空*/
{
system("cls");
printf("\n=====>No employee record!\n");
getchar();
return;
}
system("cls");
printf("\n =====>1 Search by number =====>2 Search by name\n");
printf(" please choice[1,2]:");
scanf("%d",&select);
if(select==1) /*按編號查詢*/
{

stringinput(searchinput,10,"input the existing employee number:");
p=Locate(tp,n,searchinput,"num");/*在數組tp中查找編號為searchinput值的元素,並返回該數組元素的下標值*/
if(p!=-1) /*若找到該記錄*/
{
printheader();
printdata(tp[p]);
printf(END);
printf("press any key to return");
getchar();
}
else
Nofind();
getchar();
}
else if(select==2) /*按姓名查詢*/
{
stringinput(searchinput,15,"input the existing employee name:");
p=Locate(tp,n,searchinput,"name");
if(p!=-1)
{
printheader();
printdata(tp[p]);
printf(END);
printf("press any key to return");
getchar();
}
else
Nofind();
getchar();
}
else
Wrong();
getchar();

}

/*刪除記錄:先找到保存該記錄的數組元素的下標值,然後在數組中刪除該數組元素*/
int Del(ZGGZ tp[],int n)
{
int sel;
char findmess[20];
int p=0,i=0;
if(n<=0)
{ system("cls");
printf("\n=====>No employee record!\n");
getchar();
return n;
}
system("cls");
Disp(tp,n);
printf("\n =====>1 Delete by number =====>2 Delete by name\n");
printf(" please choice[1,2]:");
scanf("%d",&sel);
if(sel==1)
{
stringinput(findmess,10,"input the existing employee number:");
p=Locate(tp,n,findmess,"num");
getchar();
if(p!=-1)
{
for(i=p+1;i<n;i++) /*刪除此記錄,後面記錄向前移*/
{
strcpy(tp[i-1].num,tp[i].num);
strcpy(tp[i-1].name,tp[i].name);
tp[i-1].jbgz=tp[i].jbgz;
tp[i-1].jj=tp[i].jj;
tp[i-1].kk=tp[i].kk;
tp[i-1].yfgz=tp[i].yfgz;
tp[i-1].jbgz=tp[i].sk;
tp[i-1].sfgz=tp[i].sfgz;
}
printf("\n==>delete success!\n");
n--;
getchar();
saveflag=1;
}
else
Nofind();
getchar();
}
else if(sel==2) /*先按姓名查詢到該記錄所在的數組元素的下標值*/
{
stringinput(findmess,15,"input the existing employee name:");
p=Locate(tp,n,findmess,"name");
getchar();
if(p!=-1)
{
for(i=p+1;i<n;i++) /*刪除此記錄,後面記錄向前移*/
{
strcpy(tp[i-1].num,tp[i].num);
strcpy(tp[i-1].name,tp[i].name);
tp[i-1].jbgz=tp[i].jbgz;
tp[i-1].jj=tp[i].jj;
tp[i-1].kk=tp[i].kk;
tp[i-1].yfgz=tp[i].yfgz;
tp[i-1].jbgz=tp[i].sk;
tp[i-1].sfgz=tp[i].sfgz;
}
printf("\n=====>delete success!\n");
n--;
getchar();
saveflag=1;
}
else
Nofind();
getchar();
}
return n;
}

/*修改記錄。先按輸入的職工編號查詢到該記錄,然後提示用戶修改編號之外的值,編號不能修改*/
void Modify(ZGGZ tp[],int n)
{
char findmess[20];
int p=0;
if(n<=0)
{ system("cls");
printf("\n=====>No employee record!\n");
getchar();
return ;
}
system("cls");
printf("modify employee recorder");
Disp(tp,n);
stringinput(findmess,10,"input the existing employee number:"); /*輸入並檢驗該編號*/
p=Locate(tp,n,findmess,"num"); /*查詢到該數組元素,並返回下標值*/
if(p!=-1) /*若p!=-1,表明已經找到該數組元素*/
{
printf("Number:%s,\n",tp[p].num);
printf("Name:%s,",tp[p].name);
stringinput(tp[p].name,15,"input new name:");

printf("jbgz:%8.2f,",tp[p].jbgz);
tp[p].jbgz=numberinput("jbgz:");

printf("jiangjin:%8.2f,",tp[p].jj);
tp[p].jj=numberinput("jiangjin:");

printf("koukuan:%8.2f,",tp[p].kk);
tp[p].kk=numberinput("koukuan:");

tp[n].yfgz=tp[n].jbgz+tp[n].jj-tp[n].kk;
tp[n].sk=tp[n].yfgz*0.12;
tp[n].sfgz=tp[n].yfgz-tp[n].sk;
printf("\n=====>modify success!\n");
getchar();
Disp(tp,n);
getchar();
saveflag=1;
}
else
{Nofind();
getchar();
}
return ;
}

/*插入記錄:按職工編號查詢到要插入的數組元素的位置,然後在該編號之後插入一個新數組元素。*/
int Insert(ZGGZ tp[],int n)
{
char ch,num[10],s[10]; /*s[]保存插入點位置之前的編號,num[]保存輸入的新記錄的編號*/
ZGGZ newinfo;
int flag=0,i=0,kkk=0;
system("cls");
Disp(tp,n);
while(1)
{ stringinput(s,10,"please input insert location after the Number:");
flag=0;i=0;
while(i<n) /*查詢該編號是否存在,flag=1表示該編號存在*/
{
if(strcmp(tp[i].num,s)==0) {kkk=i;flag=1;break;}
i++;
}
if(flag==1)
break; /*若編號存在,則進行插入之前的新記錄輸入操作*/
else
{ getchar();
printf("\n=====>The number %s is not existing,try again?(y/n):",s);
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{continue;}
else
{return n;}
}
}
/*以下新記錄的輸入操作與Add()相同*/

while(1)
{ stringinput(num,10,"input new employee Number:");
i=0;flag=0;
while(i<n) /*查詢該編號是否存在,flag=1表示該編號存在*/
{
if(strcmp(tp[i].num,num)==0) {flag=1;break;}
i++;
}
if(flag==1)
{
getchar();
printf("\n=====>Sorry,The number %s is existing,try again?(y/n):",num);
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{continue;}
else
{return n;}
}
else
break;
}

strcpy(newinfo.num,num); /*將字元串num拷貝到newinfo.num中*/
stringinput(newinfo.name,15,"Name:");
newinfo.jbgz=numberinput("jbgz:"); /*輸入並檢驗jbgz*/
newinfo.jj=numberinput("jiangjin:"); /*輸入並檢驗jiangjin*/
newinfo.kk=numberinput("koukuan:"); /*輸入並檢驗koukuan*/
newinfo.yfgz=newinfo.jbgz+newinfo.jj-newinfo.kk; /*計算yfgz*/
newinfo.sk=newinfo.yfgz*0.12; /*計算sk*/
newinfo.sfgz=newinfo.yfgz-newinfo.sk;
saveflag=1; /*在main()有對該全局變數的判斷,若為1,則進行存檔操作*/

for(i=n-1;i>kkk;i--) /*從最後一個組織元素開始往向移一個元素位置*/
{ strcpy(tp[i+1].num,tp[i].num);
strcpy(tp[i+1].name,tp[i].name);
tp[i+1].jbgz=tp[i].jbgz;
tp[i+1].jj=tp[i].jj;
tp[i+1].kk=tp[i].kk;
tp[i+1].yfgz=tp[i].yfgz;
tp[i+1].sk=tp[i].sk;
tp[i+1].sfgz=tp[i].sfgz;
}
strcpy(tp[kkk+1].num,newinfo.num); /*在kkk的元素位置後插入新記錄*/
strcpy(tp[kkk+1].name,newinfo.name);
tp[kkk+1].jbgz=newinfo.jbgz;
tp[kkk+1].jj=newinfo.jj;
tp[kkk+1].kk=newinfo.kk;
tp[kkk+1].yfgz=newinfo.yfgz;
tp[kkk+1].sk=newinfo.sk;
tp[kkk+1].sfgz=newinfo.sfgz;
n++;
Disp(tp,n);
printf("\n\n");
getchar();
return n;
}

/*統計公司的員工的工資在各等級的人數*/
void Tongji(ZGGZ tp[],int n)
{
int count10000=0,count5000=0,count2000=0,count0=0;
int i=0;
if(n<=0)
{ system("cls");
printf("\n=====>Not employee record!\n");
getchar();
return ;
}
system("cls");
Disp(tp,n);
i=0;
while(i<n)
{
if(tp[i].sfgz>=10000) {count10000++;i=i+1;continue;} /*實發工資>10000*/
if(tp[i].sfgz>=5000) {count5000++;i=i+1;continue;} /*5000<=實發工資<10000*/
if(tp[i].sfgz>=2000) {count2000++;i=i+1;continue;} /*2000<=實發工資<5000*/
if(tp[i].sfgz<2000) {count0++;i=i+1;continue;} /*實發工資<2000*/

}
printf("\n------------------------------the TongJi result--------------------------------\n");
printf("sfgz>= 10000:%d (ren)\n",count10000);
printf("5000<=sfgz<10000:%d (ren)\n",count5000);
printf("2000<=sfgz< 5000:%d (ren)\n",count2000);
printf("sfgz< 2000:%d (ren)\n",count0);
printf("-------------------------------------------------------------------------------\n");
printf("\n\npress any key to return");
getchar();
}

/*利用冒泡排序法實現數組的按實發工資欄位的降序排序,從高到低*/
void Sort(ZGGZ tp[],int n)
{
int i=0,j=0,flag=0;
ZGGZ newinfo;
if(n<=0)
{ system("cls");
printf("\n=====>Not employee record!\n");
getchar();
return ;
}
system("cls");
Disp(tp,n); /*顯示排序前的所有記錄*/
for(i=0;i<n;i++)
{
flag=0;
for(j=0;j<n-1;j++)
if((tp[j].sfgz<tp[j+1].sfgz))
{ flag=1;
strcpy(newinfo.num,tp[j].num); /*利用結構變數newinfo實現數組元素的交換*/
strcpy(newinfo.name,tp[j].name);
newinfo.jbgz=tp[j].jbgz;
newinfo.jj=tp[j].jj;
newinfo.kk=tp[j].kk;
newinfo.yfgz=tp[j].yfgz;
newinfo.sk=tp[j].sk;
newinfo.sfgz=tp[j].sfgz;

strcpy(tp[j].num,tp[j+1].num);
strcpy(tp[j].name,tp[j+1].name);
tp[j].jbgz=tp[j+1].jbgz;
tp[j].jj=tp[j+1].jj;
tp[j].kk=tp[j+1].kk;
tp[j].yfgz=tp[j+1].yfgz;
tp[j].sk=tp[j+1].sk;
tp[j].sfgz=tp[j+1].sfgz;

strcpy(tp[j+1].num,newinfo.num);
strcpy(tp[j+1].name,newinfo.name);
tp[j+1].jbgz=newinfo.jbgz;
tp[j+1].jj=newinfo.jj;
tp[j+1].kk=newinfo.kk;
tp[j+1].yfgz=newinfo.yfgz;
tp[j+1].sk=newinfo.sk;
tp[j+1].sfgz=newinfo.sfgz;
}
if(flag==0) break;/*若標記flag=0,意味著沒有交換了,排序已經完成*/
}
Disp(tp,n); /*顯示排序後的所有記錄*/
saveflag=1;
printf("\n =====>sort complete!\n");

}

/*數據存檔,若用戶沒有專門進行此操作且對數據有修改,在退出系統時, 會提示用戶存檔*/
void Save(ZGGZ tp[],int n)
{
FILE* fp;
int i=0;
fp=fopen("c:\\zggz","wb");/*以只寫方式打開二進制文件*/
if(fp==NULL) /*打開文件失敗*/
{
printf("\n=====>open file error!\n");
getchar();
return ;
}
for(i=0;i<n;i++)
{
if(fwrite(&tp[i],sizeof(ZGGZ),1,fp)==1)/*每次寫一條記錄或一個結構數組元素至文件*/
{
continue;
}
else
{
break;
}
}
if(i>0)
{
getchar();
printf("\n\n=====>save file complete,total saved's record number is:%d\n",i);
getchar();
saveflag=0;
}
else
{system("cls");
printf("the current link is empty,no employee record is saved!\n");
getchar();
}
fclose(fp); /*關閉此文件*/
}

void main()
{
ZGGZ gz[N]; /*定義ZGGZ結構體*/
FILE *fp; /*文件指針*/
int select; /*保存選擇結果變數*/
char ch; /*保存(y,Y,n,N)*/
int count=0; /*保存文件中的記錄條數(或元素個數)*/

fp=fopen("C:\\zggz","ab+");
/*以追加方式打開二進制文件c:\zggz,可讀可寫,若此文件不存在,會創建此文件*/
if(fp==NULL)
{
printf("\n=====>can not open file!\n");
exit(0);
}

while(!feof(fp))
{
if(fread(&gz[count],sizeof(ZGGZ),1,fp)==1) /*一次從文件中讀取一條職工工資記錄*/
count++;
}
fclose(fp); /*關閉文件*/
printf("\n==>open file sucess,the total records number is : %d.\n",count);
getchar();
menu();
while(1)
{
system("cls");
menu();
printf("\n Please Enter your choice(0~9):"); /*顯示提示信息*/
scanf("%d",&select);

if(select==0)
{
if(saveflag==1) /*若對數組的數據有修改且未進行存檔操作,則此標志為1*/
{ getchar();
printf("\n==>Whether save the modified record to file?(y/n):");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
Save(gz,count);
}
printf("\n===>thank you for useness!");
getchar();
break;
}

switch(select)
{
case 1:count=Add(gz,count);break; /*增加職工工資記錄*/
case 2:count=Del(gz,count);break; /*刪除職工工資記錄*/
case 3:Qur(gz,count);break; /*查詢職工工資記錄*/
case 4:Modify(gz,count);break; /*修改職工工資記錄*/
case 5:count=Insert(gz,count);break; /*插入職工工資記錄*/
case 6:Tongji(gz,count);break; /*統計職工工資記錄*/
case 7:Sort(gz,count);break; /*排序職工工資記錄*/
case 8:Save(gz,count);break; /*保存職工工資記錄*/
case 9:system("cls");Disp(gz,count);break; /*顯示職工工資記錄*/
default: Wrong();getchar();break; /*按鍵有誤,必須為數值0-9*/
}
}
}

⑹ 用c語言編寫設計,職工信息管理系統。

我給你個大概提示吧,
首先你要做的是個大體的框架
分三個許可權一是管理員許可權,人事部門許可權以及員工許可權。
1.管理員許可權實現包括員工基本信息增刪改查功能。
2.人事許可權包括員工拓展信息,比如工資,獎金等等數據的維護和更新。
3.員工許可權包括個人信息查詢以及問題反饋。
三個雙向鏈表,節點數據存入以上所有信息。
鏈表操作不多說了吧。。。
文件讀寫問題,這里考慮到如果是一般情況的話直接調用readwrite函數就行了
如果內容過多還是連接資料庫吧。
系統開始的初始化和更新也很重要。

⑺ C語言 職工信息管理系統

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>//system("cls");清屏
#include <string.h>

struct Staff { //員工信息結構體
int Number; //職工號號
char name[20]; //姓名
char sex; // 性別
int age; // 年齡
char ecation[20]; //學歷
float wages; //工資
char addr[20]; //住址
char Tel[15]; //電話
};
struct Staff Staffer[100],Staffer1;

//功能函數聲明
void menu(); //主菜單
void input(); //輸入員工信息
void save(int m); //存儲信息
int read(); // 讀取信息
void display();//瀏覽信息
void add() ; //添加
void search(); //查找
void search_name(); //按編號查找
void search_EDU(); //按學歷查找
void search_wages(); //按工資查找
void Delete(); //刪除操作
void change(); //修改操作
void order(); //排序操作
void order_Num(); //按職工號排序 //瀏覽信息時按照職工號由小到大順序排序
void order_name();//按職工姓名排序
void order_age();//按職工年齡排序

//主函數

void main()
{ int n,f;
while(1)
{
do {
menu(); //*調用菜單函數*
printf("請輸入你需要操作的序號(1-8): ");
scanf("%d",&n);
if(n>=1&&n<=8) {
f=1;

⑻ 用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語言實現公司職員信息管理系統

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 200
int id=0; /*全局變數,添加數據時自增.*/
int *p;
char delechar[]="qq1145219983";
struct score
{
int c;
int java;
int vb;
int sql;
int asp;
};
struct user /*結構體,學生數據各項屬性定義.*/
{
char name[50];
char sex[10];
char no[20];
int userid;
struct score grade ;
};
struct user users[MAX]; /*全局結構體數組,定義可存儲學生數.*/
void adser(); /*添加數據的函數說明.*/
void updateuser(); /*修改數據的函數說明.*/
void deleteuser(); /*刪除數據的函數說明.*/
void selectuser(); /*查詢數據的函數說明.*/
void selectno(); /*按學號查詢函數說明.*/
void selectall(); /*查詢全部學生函數聲明.*/
void selectgrade();
void upgrade(int a);
int average(int i);
int verify(int a);
int verifyg(int a);
int load();
void save();

int main()
{
int conn;
id=load();
system("title 學生成績信息管理系統");
printf("***************\nqq:1145219983\nMy Name:wei!\n***************\n");
for(;;) /*無限循環,用於每次執行完各操作函數時返回主菜單.*/
{
printf("\n\n\n\n"); /*主菜單開始*/
printf("***********************************\n"); /*主菜單開始*/
printf("=======學生成績信息系統============\n");
printf("***********************************\n");
printf(">>> 1 添加.\n");
printf(">>> 2 修改.\n");
printf(">>> 3 刪除.\n");
printf(">>> 4 查詢.\n");
printf(">>> 5 清屏.\n");
printf(">>> 其他任意鍵退出.\n");
printf("***********************************\n");
printf("***********************************\n\n\n");
printf("輸入操作:"); /*主菜單結束*/
scanf("%d",&conn); /*輸入數字,給全局變數conter賦值,用於判斷添加,刪除數據等操作.*/
if (conn==1||conn==2||conn==3||conn==4||conn==5) /*判斷輸入數字是否在1到5之間*/
{
switch(conn) /*如果上面判斷是在1到4間,則執行switch,判斷conter是1到4間的哪一個.*/
{
case 1 : adser(); save(); break; /*是1,則執行添加函數,轉至添加函數進行操作.*/
case 2 : updateuser(); save(); break; /*是2,則執行修改函數,轉至修改函數進行操作.*/
case 3 : deleteuser(); save(); break; /*是3,則執行刪除函數,轉至刪除函數進行操作.*/
case 4 : selectuser(); break; /*是4,則執行查詢函數,轉至查詢函數進行操作.*/
case 5 : system("cls"); break;
default : exit(0); /*都不是,則退出程序.*/
}
}
else exit(0);
}
}
void adser() /*添加數據函數,*/
{
char ch;
int i=0;
printf("姓名:");
scanf("%s",users[id].name);
printf("性別:");
scanf("%s",users[id].sex);
printf("輸入成績:\n");
printf("c語言:");
scanf("%d",&users[id].grade.c);
users[id].grade.c=verifyg(users[id].grade.c);
printf("Java:");
scanf("%d",&users[id].grade.java);
users[id].grade.java=verifyg(users[id].grade.java);
printf("Vb:");
scanf("%d",&users[id].grade.vb);
users[id].grade.vb=verifyg(users[id].grade.vb);
printf("Sql:");
scanf("%d",&users[id].grade.sql);
users[id].grade.sql=verifyg(users[id].grade.sql);
printf("Asp:");
scanf("%d",&users[id].grade.asp);
users[id].grade.asp=verifyg(users[id].grade.asp);
while(i==0)
{
printf("學號:");
scanf("%s",users[id].no);
i=verify(id);
}
if(i!=0)
{
users[id].userid=id;
id++;
printf("\n完成!\n\n");
}

}
void updateuser() /*修改數據函數,*/
{
char upno[10],ch;
int conn;
int b=0;
int i,j;
printf("輸入學號:");
scanf("%s",upno);
for(i=0;i<id;i++)
{
if(strcmp(users[i].no,upno)==0) /*遍歷所有數據,判斷輸入的學號於數據裡面的學號是否相同,不同則不執行修改.*/
{
printf("\n將要修改以下資料:\n");
printf("姓名:%s\n性別:%3s, 學號:%10s , 平均份:%3d \nC:%d , Java:%d , Vb:%d , Sql:%d , Asp:%d\n\n",users[i].name,users[i].sex,users[i].no,average(i),users[i].grade.c,users[i].grade.java,users[i].grade.vb,users[i].grade.sql,users[i].grade.asp);
printf("\n\n按任意鍵繼續,按0返回...\n\n");
ch=getch(); if(ch==48) {j=1; break;}
printf("修改: 1.姓名 , 2.性別 , 3.學號 , 4.成績 , 0.主目錄 , 其他鍵退出.\n");
printf("請選擇:");
scanf("%d",&conn);
if(conn==1||conn==2||conn==3||conn==4)
switch(conn)
{
case 1 : printf("姓名:");scanf("%s",users[i].name); j=1; printf("\n完成!\n\n"); break;
case 2 : printf("性別:");scanf("%s",users[i].sex); j=1; printf("\n完成!\n\n"); break;
case 3 : while(b==0){printf("學號:");scanf("%s",users[i].no);b=verify(i);}if(b!=0){j=1;b=0;printf("\n完成!\n\n");} break;
case 4 : j=1; upgrade(i); break;
}
else if(conn==0) {j=1; break;}
else exit(0);

if(j!=1) printf("\n沒有此學生!\n\n");
}
}
}
void upgrade(int a) //修改成績
{
int conn;
int i;
for(;;)
{
printf("修改成績: 1.C , 2.Java , 3.Vb , 4.Sql , 5.Asp , 0.主目錄 , 其他鍵退出.\n");
printf("輸入操作:");
scanf("%d",&conn);
if(conn==1||conn==2||conn==3||conn==4||conn==5)
{
switch(conn)
{
case 1 : printf("C:");scanf("%d",&users[a].grade.c); break;
case 2 : printf("Java:");scanf("%d",&users[a].grade.java); break;
case 3 : printf("Vb:");scanf("%d",&users[a].grade.vb); break;
case 4 : printf("Sql:");scanf("%d",&users[a].grade.sql); break;
case 5 : printf("Asp:");scanf("%d",&users[a].grade.asp); break;
}
printf("完成!\n\n");
}
else if(conn==0)
break;
else
exit(0);
}
}
void deleteuser() /*刪除數據函數,*/
{
char deno[10];
int i,j,k=0;
struct user temp;
printf("學號:");
scanf("%s",deno);
for(i=0;i<id;i++) /*遍歷所有數據,判斷輸入的學號於數據裡面的學號是否相同,不同則不執行刪除操作,.*/
{
if(strcmp(users[i].no,deno)==0)
{
for(j=i;j<id-1;j++)
users[j]=users[j+1];
id--;
k=1;
printf("刪除成功...\n");
}
}
if(k==0)
printf("沒有此學生!\n");
}

void selectuser() /*查詢控制函數,*/
{
int conn;
for(;;)
{
printf("***********************************\n");
printf(">>> 1.查詢全部學生.\n");
printf(">>> 2.按學號查詢.\n");
printf(">>> 0.主目錄\n");
printf(">>> 其他鍵退出.\n");
printf("***********************************\n\n");
printf("輸入操作:");
scanf("%d",&conn);
if(conn==1||conn==2)
{
switch(conn)
{
case 1 : selectall(); break;
case 2 : selectno(); break;
}
}
else if(conn==0)
break;
else
exit(0);
}
}

void selectall() /*查詢所有數據函數,*/
{
int i;
if(id==0)
{
printf("\n\n沒有數據,按任意鍵返回...\n\n");
getch();
}
else
{
printf("\n\n┏━━━━━━━━━━━━清單━━━━━━━━━━━━┓\n");
printf("┣━━━━━━━━━━━━━━━━━━━共%-6ld條記錄┫\n",id);
for(i=0;i<id;i++)
{
if(i%5==0 && i!=0)
{
printf("┃下一頁...");
getch();
}
printf("\x0d┃姓名:%-10s性別:%-6s學號:%-12s平均分:%d┃\n┃成績:[C:%d] [Java:%d] [Vb:%d] [Sql:%d] [Asp:%d] ┃\n",users[i].name,users[i].sex,users[i].no,average(i),users[i].grade.c,users[i].grade.java,users[i].grade.vb,users[i].grade.sql,users[i].grade.asp);
printf("┠——————————————————————————┨\n");
}
printf("┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n\n");
}
}

void selectno() /*按學號查詢數據函數,*/
{
char seno[10];
int i,ii=0;
printf("輸入學號:");
scanf("%s",seno);
for(i=0;i<id;i++)
{
if(strcmp(users[i].no,seno)==0)
{
printf("\n\n*****************************清單******************************\n");
printf("||%-59s||\n",users[i].name);
printf("||===========================================================||\n");
printf("||性別:[%3s], 學號:[%10s ], 平均份:[%3d ], ||\n",&users[i].sex,&users[i].no,average(i));
printf("||--------------------------<成績>---------------------------||\n");
printf("||C:[%3d ], Java:[%3d ], Vb:[%3d ], Sql:[%3d ], Asp:[%3d ], ||\n",users[i].grade.c,users[i].grade.java,users[i].grade.vb,users[i].grade.sql,users[i].grade.asp);
printf("||===========================================================||\n");
ii=1;
printf("***************************************************************\n\n\n");
}
}
if(ii!=1)
printf("沒有此學生!\n");
}
int average(int i) //平均分
{
int a;
a=(users[i].grade.c + users[i].grade.java + users[i].grade.vb + users[i].grade.sql + users[i].grade.asp)/5;
return(a);
}

int verify(int a) //驗證學號是否重復
{
int i,b;
for(i=0;i<id;i++)
{
if(i==a)
continue;

if(strcmp(users[a].no,users[i].no)==0)
{
printf("\n已有學號為%s的學生!\n重新輸入:",users[a].no);
b=0;
break;
}
else b=1;
//printf("[%s] [[%s]]\n",users[a].no,users[i].no);
}
return(b);
}

int verifyg(int a) //驗證成績是否超出范圍
{
while(a<0||a>100)
{
printf("\n錯誤.范圍:0~100 重新輸入:");
scanf("%d",&a);
}
return (a);
}

int load()
{
int num=0,i;
char temp;
FILE *fp;
if((fp=fopen("olize.dat","rb"))!=NULL)
{
fscanf(fp,"%d",&num);
//printf("[[ %d ]]\n",num);
for(i=0;i<num;i++)
{
fscanf(fp,"%s%s%s%d%d%d%d%d",users[i].name,users[i].sex,users[i].no,&users[i].grade.c,&users[i].grade.java,&users[i].grade.vb,&users[i].grade.sql,&users[i].grade.asp);
//printf("[[%s,%s,%s,%d,%d,%d,%d,%d]]\n\n",users[i].name,users[i].sex,users[i].no,users[i].grade.c,users[i].grade.java,users[i].grade.vb,users[i].grade.sql,users[i].grade.asp);
}
fclose(fp);
}
return (num);
}

void save()
{
int num,i,j;
struct user temp;
FILE *fp;
if((fp=fopen("olize.dat","wb"))==NULL)
{
printf("保存數據失敗,數據文件無法打開...\n\n\n按任意鍵退出...");
getch();
exit(0);
}
for(i=0;i<id;i++)
for(j=i+1;j<id;j++)
if(average(i)<average(j))
{temp=users[i];users[i]=users[j];users[j]=temp;}
fprintf(fp,"%d\r\n",id);
for(i=0;i<id;i++)
fprintf(fp,"%-15s%-4s%-20s%-4d%-4d%-4d%-4d%-4d\r\n",users[i].name,users[i].sex,users[i].no,users[i].grade.c,users[i].grade.java,users[i].grade.vb,users[i].grade.sql,users[i].grade.asp);
fclose(fp);
}
這份代碼是學生成績信息,你修改一下就好啦,本質上一樣的

⑽ c語言課程設計——職工信息管理系統

#include<stdio.h>
#include<string.h>
int main()
{
void TestOnLineTeacherManage(); //聲明教師信息管理函數
void TestOnLineSelfManage();//聲明個人管理函數
int n;
printf(「0教師管理,1個人管理」);
scanf(「%d」,&n);
If (n==0)
TestOnLineTeacherManage();
else
TestOnLineSelfManage();//選擇教師管理或者個人信息管理
Return 0;
}

Void TestOnLineTeacherManage() //教師信息管理函數
{
Struct TestOnLineTeacher
{
Int Tnum;
Char Tname[20];
Char Tsex;
Char Ttel[20];
}Teacher[100]; //定義一個結構體
void add(); //定義教師信息添加
void del(); //定義教師信息刪除
Void modify(); //定義教師信息修改
int a;
Printf(「1添加2刪除3修改」);
Scanf (「%d」,&a);
Switch(a)
{
Case1:add();break;
Case2:del();break;
Case3:modify();break;
Default:break;
}//選擇功能
}

Void add() //教師信息添加函數,若添加Teacher[i]
{
printf(「輸入工號」);
Scanf(「%d」,&Teacher[i].Tnum);
printf(「輸入姓名」);
Scanf(「%s」,&Teacher[i].Tname);
printf(「輸入性別f女m男」);
Scanf(「%c」,&Teacher[i].Tsex);
printf(「輸入電話」);
Scanf(「%s」,&Teacher[i].Ttel);
}

Void del() //教師信息刪除函數,若刪除Teacher[i]
{
Teacher[i-1]=Teacher[i+1];
Free(Teacher[i]);
}

Void modify() //教師信息修改函數,若修改Teacher[i]
{
Int t;
Int num;
Char name[20];
Char sex;
Char tel[20];
Printf(「修改選項1工號2姓名3性別4電話」);
Scanf(「%d」,&t);
Switch(t)
{
Case1:scanf(「%d」,&num);Teacher[i].Tnum=num;break;
Case2:scanf(「%s」,&name);strcpy(Teacher[i].Tname,name);break;
Case3:scanf(「%c」,&sex);Teacher[i].Tsex=sex;break;
Case4:scanf(「%s」,&tel);strcpy(Teacher[i].Ttel,tel);break;
Default:break;
}//選擇修改項並修改
}

Void TestOnLineSelfManage() //個人信息管理
{
Struct TestOnLineManage
{
Int Mnum;
Char Mname[20];
Char Msex;
Char Mtel[20];
}Manage[1]; //定義一個結構體
Int b;
Int num;
Char name[20];
Char sex;
Char tel[20];
Printf(「修改選項1工號2姓名3性別4電話」);
Scanf(「%d」,&b);
Switch(t)
{
Case1:scanf(「%d」,&num);Manage[1].Mnum=num;break;
Case2:scanf(「%s」,&name);strcpy(Manage[1].Mname,name);break;
Case3:scanf(「%c」,&sex);Manage[1].Msex=sex;break;
Case4:scanf(「%s」,&tel);strcpy(Manage[1].Mtel,tel);break;
Default:break;
}//選擇修改項並修改
}