⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datestruct.cpp

📁 tc 2.0下用680*480 256 色模式下写成的中文菜单程序
💻 CPP
字号:
#definetruct work{ int cardmun;      /*职工基本信息*/
             int idtification;
             char name[20];
             int  sex;
             int  age;
             int  workyear;
             char zhicheng[15];
             char bianhao; 
             char section; 
             char homephone[10];
             char mobiephone[11];
             struct work *next;
             struct payroll *p;
             int month;       /*当前月数*/
            };

struct salary{float pay;                   /*应发工资*/
              float  basesalary;     /*基本工资*/
              float  salary;          /*职务工资*/
              float   grant;                         /*补助*/
              float award;               /*特别奖励*/
              };

struct  reduce{                         //费用扣除信息
               float Water;/*水费*/
               float Electricity;
               float Clealing;
               float costs;/*闭路电费*/
              }

struct payroll{
               int month;             /*每月工资单数据*/
               struct salary a;
               struct reduce b;
               float taxs;
               float paywage;               /*实发工资数*/
               struct payroll *next;
              }
                                            //部门
struct section{
                int mun;  //人数
                char name[20];//部门名称
                struct section *next;
                struct work *p;
               }



int readline(char *P)  //读取字符串
{   int num=0;
    char c;
    while((c=getchar())!='\n')
    {   *p=c;
        num++;
    }
    return num;
}

struct section *findsection(struct section *phead,char *section) //寻找部门
{    struct section *p;
     for(p=phead;p!=NULL;p=p->next)
            if(strcmp(p->name,section)==0)
               return p;
      return NULL;
}

struct work *findwork(struct section *phead,char *name)
{
      struct section *ptr;
      struct work *p;
      for(ptr=phead;ptr!=NULL;ptr=ptr->next)
          for(p=ptr->p;p!=NULL;p=p->next)
            if(strcmp(name,p->name)==0)
               return p;
      return NULL;   
}


               
int addsection(struct section *phead, char *name)//增加部门
{   
    q=(struct section*)malloc(sizeof(struct section));
    if(p==NULL)
    {
		diaologe("内存不够");
        return 0;
    }      
     q->next=phead;   /*后进先出*/
     phead=q; 
     q->mun=0;
     strcpy(q->name,name);
     p->p=NULL;
     return 1; 
 }

int addwork(struct section *phead,struct work *p, char *section)//增加职工
{    struct section *q;
     struct work *a;
     if(q=findsection(phead,section)==NULL)
	 {
		 diaologe("无法找到");
		 return 0;
	 }
	 q->mun++;           /*后进先出*/
	 p->next=q->p;
     q->p=p;
   	 return 1;
}

int addsalary(struct work *p,struct payroll *q)
{

	struct payroll *new=q,*last,*current;
	current=p->p;
	while(q->month>current->month&&current->next!=NULL)
	{
		last=current;
		current=current->next;
	}
	if(q->month==current->month)
	{
		diaologe("输入重复");
		return 0;
	}
	if(q->month<current->month)
		if(current==p->p)
		{
			new->next=p->p;
			p->p=new;
		}
		else
		{
			new->next=current;
			last->next=new;
		}
   else
   {
	   new->next=NULL;
	   current->new;
	}
}



int deletesection(struct section *phead, char *section)//删除部门   
    { struct section *head,*tail;
      struct work *a,*b;
      head=tail=phead;
      tail=tail->next;
      while(tail!=NULL&&strcmp(tail->name,section)!=0)
           { tail=tail->next;
            head=head->next; 
            }   
        
      if(tail!=NULL)
         {head->next=tail->next;
          a=b=tail->p;
          free(tail);
           b=b->next; 
          while(b)
            {free(a);
             a=b;
             b=b->next;
            }
          }
     }    
     else if((tail==NULL)&&(strcmp(phead->name,section))
          {
           a=b=phead->p;
          phead=phead->next;
          free(phead);
           b=b->next; 
          while(b)
            {free(a);
             a=b;
             b=b->next;
            }
          }
     }

int delete_work(struct section *phead,struct section sec,char *name)
{
    struct section *ptr;
    struct work *head,*tail;
    for(ptr=phead;ptr!=NULL;ptr=ptr->next)
    {
        if(strcmp(sec.name,ptr->name)==0))
    	{
            head=tail=ptr->p;
            if(strcmp(head->name,name)==0)   /*如果是第一个*/
    		{
                ptr->p=head->next;
                return 1;
    		}
        	else 
    		{
                head=head->next;
                for(;head!=NULL;head=head->next)
        		{
                    if(strcmp(head->name,mane)==0)
        			{
                        tail->next=head->next;
                        free(head->p);     /*释放空间*/
                    	free(head); 
                		return 1;
        			}
                    tail=tail->next;
        		}
    		}
    	}
    }
    if(ptr==NULL)
    {
        dialoge("无法找到");
        return 0;
    }
}
                         
    
           
void statistics_age(int *age1,int *age2,int *age3,struct section *phead)
{
    struct work *worker;
    struct section *ptr;
    *age1=0;
    *age2=0;
    *age3=0;
    for(ptr=phead;p->next!=NULL;p=p_>next)
       for(worker=ptr->p;worker->next!=NULL;worker=worker->next)
       {
           if(worker->age<20)
              *age1=*age1+1;
           else if(worker->age>=20&&worker->age<45)
              *age2=*age2+1;
           else if(worker>=55)
              *age3=*age3+1;
       }
}

int cal_tax(float salary)
{
    float tax;
    if(salary<800)
        tax=0;
    else if(salary>=800&&salary<=1400)
         tax=(tax-800)*0.05;
    else if(salary>1400)
         tax=(tax-1400)*0.1;
    return tax;
}


void statistics_tax(folat *tax_month,float *tax_year,struct section *phead)
{
    struct section *ptr;
    struct worker *p;
    struct payroll *h;
    int i;
    for(i=0;i<12;i++)
       tax_month[i]=0;
    *tax_year=0;
    for(ptr=phead;ptr->next!=NULL;ptr=ptr->next)
        for(p=ptr->p;p!=NULL;p=p->next)
            for(q=p->p;q!=NULL;q=q->next)
                                 tax_month[q->month-1]+=q->taxs;
    for(i=0;i<12;i++)
       tax_year+=tax_month[i];
}



void statistic_zhicheng(int month,char *zhicheng,struct salary *wage,struct section *phead )
{
    struct section *ptr;
    struct work *worker;
    struct payroll *q;
    wage->pay=wage->basesalary=wage->salary=wage->grant=wage->award=0;
    for(ptr=phead;ptr!=NUll;ptr=ptr->next)
        for(worker=ptr->p;worker!=NULL;worker=worker->next)
            if(strcmp(zhicheng,worker->zhicheng)==0)
            {
                for(q=worker->p;q!=NULL;q=q->next)
                {
                    if(month==q->month)
                    {
                     wage->pay+=(q->a).pay;
                     wage->basesalary+=(q->a).basesalary;
                     wage->salary+=(q->a).salary;
                     wage->grant+=(q->a).grant;
                     wage->award+=(q->a).award;
                    }
                 }
             }
    }
}

double statistic_salay(int month,char *zhicheng[],int mun,struct section *phead)
{
    struct salary salay;
    int i;
    double sum=0;
    for(i=0;i<mun;i++)
    {
      statistic_zhicheng(month,zhicheng[i],&salary,phead);
      sum=sum+wage->pay+wage->basesalary+ wage->salary+wage->grant+wage->award;
    }
    return sum;
}


            /*统计技术员工数和工资总额*/
 void statistic_worker(char *zhicheng[],int munber[],int mun,float *salary[],struct section *phead)
{
    struct  section *ptr;
    struct  work *p;
    struct  payroll *q;
    int i;
    for(i=0;i<mun;i++)
    {
         munber[i]=0;
         salary[i]=0;
     }
     for(ptr=phead;ptr!=NULL;ptr=ptr=ptr->next)
         for(p=ptr->p;p!=NULL;p=p->next)
             for(i=0;i<mun;i++)
             {
                 q=p->p;
                 if(strcmp(q->zhicheng==zhicheng[i]))
                 {
                    number[i]++;
                    salary[i]+=q->paywage;
                  }
              }
      for(i=0;i<mun;i++)
            salary[i]=salary[i]/number[i];
}

int sort(int month,struct section *phead)   /*对某月全公司员工应发工资进行排序*/
{
    struct section *ptr;
    struct work *p,*temp;
    struct work **pt;
    struct payroll *q;
    int munber=0,i=0;
    int j;
    float pay1,pay2;
    if(month<1&&month<(phead->p)->month)
    {
        diagoe("非法输入");
        return -1;
    }
    for(ptr=phead;ptr!=NULL;ptr=ptr->next)  /*统计员工数*/
        munber+=ptr->mun;
    pt=(struct work **)calloc(munber,sizeof(struct work *))
    for(ptr=phead;ptr!=NULL;ptr=ptr->next)  /*把员工的地址保存在pt中*/
        for(p=ptr->p;p!=NULL;p=p->next)
    	{
            pt[i]=p;
        	i++;
    	}
   for(i=0;i<munber-1;i++)                 /*利用指针进行排序*/
       for(j=i+1;j<munber;i++)
       {
          for(q=pt[i]->p;q!=NULL;q=q->next)
              if(q->month==month)
                  pay1=(q->a).pay;
          for(q=pt[i+1]->p;q=!NULL;q=q->next)
              if(q->month==month)
                  pay2=(q->a).pay;
         if(pay1<pay2)
             temp=pt[i],p[i]=p[i+1],p[i+1]=temp;
       }
    show_result(pt,munber);
    free(pt);
    return 1;
}
                            



    
     


    



















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -