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

2016-02-19 13:13 3 1 收藏

关注图老师设计创意栏目可以让大家能更好的了解电脑,知道有关于电脑的更多有趣教程,今天给大家分享简单的职工管理系统(V1.1修改版)内含中文注释教程,希望对大家能有一点小小的帮助。

【 tulaoshi.com - 编程语言 】

/*------------------------------------------------------------------------
   * 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.                */
  /*                         */
  /*[]---------------------------------------------------[]*/
  #includestdlib.h
  #includestring.h
  #includectype.h
  #includestdio.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("Now add NO. %d worker's profile",*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:");
    printf("Year:");
    scanf("%4d",&add_birthday_year);
       if(add_birthday_year9999 add_birthday_year0){
           status=false;puts("input error,the year of birthday cannot more than 9999 or less than 0!");
           continue;
        }
       else
          status=true;
  printf("Month:");
    scanf("%2d",&add_birthday_month);
       if(add_birthday_month12 add_birthday_month1){
           status=false;puts("input error,the month of birthday cannot be more than 12 or less than 1");
           continue;
        }
       else
          status=true;
  printf("Day:");
    scanf("%2d",&add_birthday_day);
       if(add_birthday_day31 add_birthday_day1){
           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:");
    printf("Year:");
    scanf("%4d",&add_workday_year);
       if(add_workday_year9999 add_workday_year0){
           status=false;puts("input error,the year of workday cannot more than 9999 or less than 0!");
           continue;
        }
       else
          status=true;
  printf("Month:");
    scanf("%2d",&add_workday_month);
       if(add_workday_month12 add_workday_month1){
           status=false;puts("input error,the month of workday cannot be more than 12 or less than 1");
           continue;
        }
       else
          status=true;
  printf("Day:");
    scanf("%2d",&add_workday_day);
       if(add_workday_day31 add_workday_day1){
           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] 

来源:https://www.tulaoshi.com/n/20160219/1603417.html

延伸阅读
一、功能   提供软件的一般用户治理系统 二、设计思路及程序实现     1.建立的表:以下表在建立时应该先加密码,程序打开时才由程序传递密码。以避免直接用工具可打开DB文件。          ① 用户资料表      ...
系统管理命令中文详解 whois 功能说明:查找并显示用户信息。 语 法:whois [帐号名称] 补充说明:whois指令会去查找并显示指定帐号的用户相关信息,因为它是到Network Solutions的WHOIS数据库去查找,所以该帐号名称必须在上面注册方能寻获,且名称没有大小写的差别。 ------------------------------------------------...
win7系统中文件背景颜色的修改方法   在这个90当道的年代,个性成为了关键词,电脑桌面自定义更是成为必不可少的东西,电脑自带的那些壁纸完全不能满足他们的口味了,图片不仅要采用自 己选择的,而且有时还会设置动态壁纸,几秒钟不断的更换,现在有用户提问说win7旗舰版电脑中文件的背景怎么修改?已经不再满足于单纯背景的更换了,...
标签: windows 操作系统
    alerter----错误警报器,一般没什么用 application layer gateway service----给与第三者网络共享/防火墙支持的服务,有些防火墙/网络共享软件需要。约占用1.5MB内存。 application management----用于设定,发布和删除软件服务。 automatic updates----windows自动更新,可以考虑关闭,但会存在安全隐...
OOo支持的文档格式比较多,以下为简体中文下载地址: http://planetmirror.com/pub/openoffice/contrib/rc/1.1rc3/OOo_1.1rc3_030813_LinuxIntel_install_zh-CN.tar.gz (澳大利亚) ftp://ftp.gnupilgrims.org/pub/OpenOffice.org/contrib/rc/1.1rc3/OOo_1.1rc3_030813_LinuxIntel_install_zh-CN.tar.gz (香港) ftp://ftp.nctu.edu.tw/OpenO...

经验教程

107

收藏

6
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部