标题:统计员工信息程序做?
取消只看楼主
R君
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2019-5-19
结帖率:100%
 问题点数:0 回复次数:0 
统计员工信息程序做?
按年龄,性别,工作统计员工信息,请问各位我的这个程序该怎么改?
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
char filename[20];
FILE *fp;

struct date
{int year;
int mouth;
int day;
};
struct person
{ char name[10];
int age;
char job[10];
char sex[10];
char address[10];
char phone[10];
struct date in_time;
}worker[MAX];
void count_age( )
{int i,j,n;
int agekey;
n=65;
j=0;
system("CLS");
printf("******输入要统计员工的年龄******\n");
scanf("%d",&agekey);
for(i=0;i<n;i++)
    if(worker[i].age==agekey)
    {printf("******员工信息******\n");
printf("姓名\t年龄\t性别\t地址\t电话\t入厂时间\n");
printf("%s\t%d\t%s\t%s\t%s\t%s\t%d-%d-%d\n",worker[i].name,worker[i].age,worker[i].job,worker[i].sex,worker[i].address,worker[i].phone,
    worker[i].in_time.year,worker[i].in_time .mouth ,worker[i].in_time.day );
}
    else j++;
    if(j==n)
        printf("******暂无该年龄段员工******\n");
    printf("******按任意键返回主菜单******\n");
    getchar();
}
void count_job(int n)
{ int i,j; char jobkey[10];

j=0;
system("CLS");
printf("******输入要统计员工的职务******\n");
scanf("%s",&jobkey);
for(i=0;i<n;i++)
    if(strcmp(worker[i].job,jobkey)==0)
    {printf("******员工信息******\n");
printf("姓名\t年龄\t工作\t性别\t地址\t电话\t入厂时间\n");
printf("%s\t%d\t%s\t%s\t%s\t%s\t%d-%d-%d\n",worker[i].name,worker[i].age,worker[i].job,worker[i].sex,worker[i].address ,worker[i].phone ,
    worker[i].in_time.year ,worker[i].in_time.mouth ,worker[i].in_time.day );
}
    else j++;
    if(j==n)
        printf("******暂无该职务或该职务暂无人******\n");
    printf("******按任意键返回主菜单******\n");
    getchar();
}


void count_sex(int n)
{int i,j,n;char sexkey[10];

j=0;
system("CLS");
printf("******输入要统计员工的性别******\n");
scanf("%s",&sexkey);
for(i=0;i<n;i++)
    if(strcmp(worker[i].sex,sexkey)==0)
    {  printf("******员工信息******\n");
printf("姓名\t年龄\t工作\t性别\t地址\t电话\t入厂时间\n");
printf("%s\t%d\t%s\t%s\t%s\t%s\t%d-%d-%d\n",worker[i].name,worker[i].age,worker[i].job,worker[i].sex,worker[i].address ,worker[i].phone ,
    worker[i].in_time.year ,worker[i].in_time.mouth ,worker[i].in_time.day );
}
    else j++;
    if(j==n)
        printf("******暂无该性别员工******\n");
    printf("******按任意键返回主菜单******\n");
    getchar();
}
void count()
{int i;
do
{system("CLS");
printf("\n\n\n******统计员工信息******\n\n");
printf("        按1,统计某年龄职工.\n\n");
printf("        按2,统计某职务职工.\n\n");
printf("        按3,统计某性别职工.\n\n");
printf("        按0,返回主菜单.\n\n");
printf("        请选择(0-3):\n");
scanf("%d",&i);
switch(i)
{case 1:count_age();break;
 case 2:count_job();break;
 case 3:count_sex();break;
 case 0:break;
 default:printf("输入错误\n");
}
}while(i!=0);
}
搜索更多相关主题的帖子: 统计 员工 信息 int printf 
2019-05-24 11:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494916-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013102 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved