网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C/C++
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.在vc++系统中编译和运行c语言.
.C++中函数指针数组的使用.
.C语言的特点.
.根据接受的数字在控制台打印出各.
.实例解析C++/CLI的串行化.
.如何检测Sniffer.
.C++ 泛型编程系列讲座之实施.
.1.2 C 语言的特点.
.Snake.Net中的线性表.
.C++/CLI中实现singleton模式.
.C++ sizeof 使用规则及陷阱分析.
.C语言入门之结构(1).
.C/C++编程新手错误分析.
.C++ 代码优化.
.用C编写Windows服务程序的五个步.
.一个画抛物线的程序.
.vb.net实现一个自定义类数组的排.
.C语言中的面向对象(2)-C语言的多.
.C++箴言:避免返回对象内部构件的.
.C++ Builder 可视化组.

员工管理系统(链表)

发表日期:2008-3-8



  #include <stdio.h>
#include <conio.h>
#include <process.h>
#define OUTPUT temp->num,temp->name,temp->gender,temp->age,temp->department,temp->telephone,temp->wage
#define FORMAT "%-10lu%-13s%-9c%-6u%-18s%-13lu%lu\n"
#define INFO "number\t  name\t       gender\tage   department\ttelephone    wage\n"
 
char ch;
unsigned int mn,fn,find;
unsigned long msum,fsum;
strUCt workers
{
 char name[15],department[18],gender;
 unsigned int age;
 unsigned long telephone,wage,num;
 struct workers *next;
};struct workers *head,*bottom,*temp,*p;
create()
{
 int i;
 head=NULL;
 mn=fn=msum=fsum=0;
 for (i=0;;i++)
 {
  printf("\n   Information of worker NO.%d(Press '*' when input worker's name if finish)",i+1);
  insert();
 }
 getch();
 return main();
}
analysis()
{
 clrscr();
 printf("\n**********************************Wage report*********************************\n");
 printf(INFO);
 temp=head;
 while(temp!=NULL)
 {
  printf(FORMAT,OUTPUT);
  temp=temp->next;
 }
 if(head==NULL)
  printf("\n\t\t\t\No worker in list,please entry first!");
 showreport();
}
showreport()
{
 FILE *report;
 report=fopen("report.dat","w");
 fprintf(report,"\n\n\tGender\t\t\tFemale\t\tMale\t\tTotal");
 fprintf(report,"\n\tNumber\t\t\t%d\t\t%d\t\t%d",fn,mn,fn+mn);
 fprintf(report,"\n\tTotal wage\t\t%lu\t\t%lu\t\t%lu",fsum,msum,fsum+msum);
 if(mn==0&&fn==0)
  fprintf(report,"\n\tAverage wage\t\t0.00\t\t0.00\t\t0.00");
 else if(fn==0)
  fprintf(report,"\n\tAverage wage\t\t0.00\t\t%.2f\t\t%.2f",(float)(msum/mn),(float)(msum/mn));
 else if(mn==0)
  fprintf(report,"\n\tAverage wage\t\t%.2f\t\t0.00\t\t%.2f",(float)(fsum/fn),(float)(fsum/fn));
 else
  fprintf(report,"\n\tAverage wage\t\t%.2f\t\t%.2f\t\t%.2f",(float)(fsum/fn),(float)(msum/mn),(float)((fsum+msum)/(fn+mn)));
 ch=fgetc(report);
 fclose(report);
 report=fopen("report.dat","r");
 while(feof(report)==0)
 {
  putchar(ch);
  ch=fgetc(report);
 }
 fclose(report);
}
search()
{
 unsigned long fnum;
 find=0;
 temp=head;
 do
 {
  printf("\nWorker's number you want to find:");
  fflush(stdin);
  scanf("%lu",&fnum);
  if(fnum<1fnum>100000000)
   printf("\tWorker's number is required from 1 to 100000000!");
 }while(fnum<1fnum>100000000);
 while(temp->next!=NULL&&fnum!=temp->num)
 {
  p=temp;
  temp=temp->next;
 }
 if(fnum==temp->num)
 {
  find=1;
  printf("\n");
  printf(INFO);
  printf(FORMAT,OUTPUT);
 }
 else
 {
  find=0;
  printf("\n\t\t\tNot found this worker!");
 }
}
insert()
{
 if(head==NULL)
 {
  bottom=temp=(struct workers *)malloc(sizeof(struct workers));
  head=temp;
 }
 else
 {
  temp=(struct workers *)malloc(sizeof(struct workers));
  bottom->next=temp;
 }
 do{
  printf("\nWorker's name:");
  fflush(stdin);
  scanf("%s",temp->name);
  if(strlen(temp->name)>15)
   printf("\tThe length of worker's name must less than 15!");
 }while(strlen(temp->name)>15);
 if (temp->name[0]!='*')
 {
  add();
  bottom->next=temp;
  bottom=temp;
 }
 else
 {
  free(temp);
  bottom->next=NULL;
  if(fn+mn==0)
   head=NULL;
  printf("\n\t\t\t\Entry finish,press any key to return...");
  getch();
  return main();
 }
 bottom->next=NULL;
}
add()
{
 do{
  printf("Worker's number:");
  fflush(stdin);
  scanf("%lu",&temp->num);
  if(temp->num<1temp->num>100000000)
   printf("\tWorker's number is required from 1 to 100000000!\n");
 }while(temp->num<1temp->num>100000000);
 do
 {
  printf("Worker's gender('m','f','M'or'F'):");
  fflush(stdin);
  scanf("%c",&temp->gender);
  if((temp->gender!='m')&&(temp->gender!='f')&&(temp->gender!='M')&&(temp->gender!='F'))
   printf("\tPlease input as 'm','f','M'or'F'!\n");
 }while((temp->gender!='m')&&(temp->gender!='f')&&(temp->gender!='M')&&(temp->gender!='F'));
 do
 {
  printf("Worker's age:");
  fflush(stdin);
  scanf("%u",&temp->age);
  if(temp->age<=18temp->age>=100)
   printf("\tWorker's age must more than 18 and less than 100!\n");
 }while(temp->age<=18temp->age>=100);
 do{
  printf("Worker's department:");
  fflush(stdin);
  scanf("%s",&temp->department);
  if(strlen(temp->department)>18)
   printf("\tThe length of worker's department must less than 18!\n");
 }while(strlen(temp->department)>18);
 do
 {
  printf("Worker's telephone(8 digit):");
  fflush(stdin);
  scanf("%lu",&temp->telephone);
  if(temp->telephone>99999999temp->telephone<10000000)
   printf("\tContact telephone is 8 digit!\n");
 }while(temp->telephone>99999999temp->telephone<10000000);
 do
 {
  printf("Worker's wage(more than 100):");
  fflush(stdin);
  scanf("%lu",&temp->wage);
  if(temp->wage<100)
   printf("\tThis worker's wage mustn't below 100!\n");
 }while(temp->wage<100);
 if((temp->gender=='m')(temp->gender=='M'))
 {
  msum+=temp->wage;
  mn++;
 }
 else
 {
  fsum+=temp->wage;
  fn++;
 }
}
delete()
{
 search();
 if(find==1)
 {
  printf("\n Do you want to delete this worker?(Y/N)");
  fflush(stdin);
  ch=getchar();
  if(ch=='y'ch=='Y')
  {
   if(temp==head)
    head=temp->next;
   else
    p->next=temp->next;
   if(temp->gender=='m'temp->gender=='M')
   {
    msum-=temp->wage;
    mn--;
   }
   else if(temp->gender=='f'temp->gender=='F')
   {
    fsum-=temp->wage;
    fn--;
   }
   free(temp);
   analysis();
   printf("\n\n\n\t\t\tDelete OK,press any key to return...");
   getch();
   return m

上一篇:约瑟夫环C语言 人气:2180
下一篇:有趣的分形学Mandlbrot集图形的一个C语言实现 人气:516
浏览全部C/C++的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐