国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

簡單的職工管理系統(V1.1修改版)內含中文注釋

2019-11-17 05:35:39
字體:
來源:轉載
供稿:網友
/*------------------------------------------------------------------------
 * 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 100FILE *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] 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 祁门县| 远安县| 丰宁| 昌吉市| 精河县| 珠海市| 阿拉善左旗| 宁南县| 淳安县| 常山县| 左贡县| 岳普湖县| 东丰县| 浦北县| 远安县| 定州市| 阜新| 邵阳市| 平和县| 土默特左旗| 云南省| 岳阳市| 潼南县| 余庆县| 亚东县| 凌源市| 当阳市| 景洪市| 东海县| 平罗县| 陇川县| 峡江县| 江口县| 廊坊市| 台安县| 筠连县| 都安| 黄陵县| 河间市| 墨竹工卡县| 新绛县|