分享
 
 
 

简单的职工管理系统(V1.1修改版)内含中文注释

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

/*------------------------------------------------------------------------

* filename - workmanagerment.c

*

* written by

* 沈豪杰(01213229)&&王鹏(01213208)

*-----------------------------------------------------------------------*/

/*[]---------------------------------------------------[]*/

/* */

/* Turbo C Run workmanagerment.c- Version 1.1 */

/* */

/* */

/* Copyright (c) 2003 6 28 by shj and wp */

/* All Rights Reserved. */

/* */

/*[]---------------------------------------------------[]*/

#include<stdlib.h>

#include<string.h>

#include<ctype.h>

#include<stdio.h>

#define maxworker 100

FILE *fp; /*定义全局变量fp,指向数据库文件 worker.txt*/

strUCt date{ /*日期的结构,用于存储工人的生日,工作日期等*/

int year;

int month;

int day;

};

struct address { /*地址的结构, 用于存储工人的地址*/

char province[10];

char city[10];

char street[20];

};

struct WORKER { /*工人的资料总结构*/

char name[20];

enum {male,female}sex;

struct date birthday;

enum {elesch,middle,high,university,other}rofs;

struct date workday;

int workeri;

char position[20];

struct address addr;

int workerj;

char tel[13];

};

/*程序的初始化函数,用于从数据库中读出现存的资料到内存中*/

data_load(int *i,struct WORKER *p){

char c;

long int k;

fp=fopen("worker.txt","r");

if(!fp){fopen("worker.txt","w+");*i=0;}

else{

for((*i)=0;(*i)<maxworker;(*i)++){

if(feof(fp)) return;

c=fgetc(fp);

if(c==EOF) return;

fflush(stdin);

k=*i;

fseek(fp,k*sizeof(struct WORKER),SEEK_SET);

fread(&p[*i],sizeof(struct WORKER),1,fp);

}

}

fclose(fp);

}

/*添加一个工人的资料*/

void add(int *i,struct WORKER *profile){

char add_name[20],add_position[20],add_addr_province[20],add_addr_city[20],add_addr_street[30],add_tel[13];

int add_birthday_year,add_birthday_month,add_birthday_day,add_workday_year,add_workday_month,add_workday_day;

int add_sex,add_rofs;

enum {false,true}status;

status=false;

printf("\n\tNow add NO. %d worker's profile\n",*i+1);

/*以下是处理输入的循环,可能有些繁杂,希望高手给指点一下

其中status是个flag,用于指定是否有输错的地方,假如有的话,

马上跳的最初的提示。

*/

while(status==false){

printf("Enter the name of the worker:");

scanf("%s",add_name);

if(strlen(add_name)==0 strlen(add_name)>20){

status=false;puts("input error,name cannot over 8 character or less than 0 character!");

continue;

}

else

status=true;

printf("Enter the gender of worker:(1=>female,0=>male)");

scanf("%d",&add_sex);

if(add_sex!=0 && add_sex!=1){

status=false;puts("only 0 or 1 can be accepted!");

continue;

}

else

status=true;

printf("Enter the birthday of worker:\n");

printf("\tYear:");

scanf("%4d",&add_birthday_year);

if(add_birthday_year>9999 add_birthday_year<0){

status=false;puts("input error,the year of birthday cannot more than 9999 or less than 0!");

continue;

}

else

status=true;

printf("\tMonth:");

scanf("%2d",&add_birthday_month);

if(add_birthday_month>12 add_birthday_month<1){

status=false;puts("input error,the month of birthday cannot be more than 12 or less than 1");

continue;

}

else

status=true;

printf("\tDay:");

scanf("%2d",&add_birthday_day);

if(add_birthday_day>31 add_birthday_day<1){

status=false;puts("input error,the year of birthday cannot be more than 31 or less than 1!");

continue;

}

else

status=true;

printf("Enter the workday of worker:\n");

printf("\tYear:");

scanf("%4d",&add_workday_year);

if(add_workday_year>9999 add_workday_year<0){

status=false;puts("input error,the year of workday cannot more than 9999 or less than 0!");

continue;

}

else

status=true;

printf("\tMonth:");

scanf("%2d",&add_workday_month);

if(add_workday_month>12 add_workday_month<1){

status=false;puts("input error,the month of workday cannot be more than 12 or less than 1");

continue;

}

else

status=true;

printf("\tDay:");

scanf("%2d",&add_workday_day);

if(add_workday_day>31 add_workday_day<1){

status=false;puts("input error,the year of workday cannot be more than 31 or less than 1!");

continue;

}

else

status=true;

[1] [2] [3] [4] [5] [6]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有