c语音吧 关注:3,055贴子:3,196
  • 0回复贴,共1

求大佬指导

只看楼主收藏回复

请问有大佬知道我这个代码哪里出问题了吗?代码是:
#include<stdio.h>
#include <string.h>
#define N 2
struct Employee /*定义结构体类型*/
{
int num[10];
char name[20];
char sex;
int age;
char dept; /*用部门首字母表示*/
char address[50];
int salary;
char education[20];
}Employee[N];
input() /*定义input函数,用于输入数据*/
{
int i;
for(i=0;i<N;i++)
{
printf("\n输入第%个职工的工号,姓名,性别,年龄,部门,地址,基本工资,教育水平:\n",i+1);
scanf("%d,%s,%c,%d,%c,%s,%d,%s",&Employee[i].num,&Employee[i].name,&Employee[i].sex,&Employee[i].age,&Employee[i].dept,&Employee[i].address,&Employee[i].salary,&Employee[i].education);
}
}
output() /*定义查找档案函数*/
{
char str[20],j;
int g,u;
{
scanf("%s",&str[20]);
for(g=0;g<N;g++)
;
if(strcmp(str[20],Employee[g].name)==0)
printf("%d,%s,%c,%d,%c,%s,%d,%s",Employee[g].num,Employee[g].name,Employee[g].sex,Employee[g].age,Employee[g].dept,Employee[g].address,Employee[g].salary,Employee[g].education);
}
{
printf("\n请输入部门");
scanf("%s",&j);
for(u=0;u<N;u++)
if(strcmp(j,Employee[u].dept)==0)
printf("%d,%s,%d",Employee[u].num,Employee[u].name,Employee[u].salary);
}
}
int max() /*定义最大工资函数*/
{
int i,a;
for(i=0;i<N;i++)
a=(Employee[i].salary>Employee[i+1].salary)?Employee[i].salary:Employee[i+1].salary;
printf("max=%d\n",a);
return 0;
}
int min() /*定义最小工资函数*/
{
int i,a;
for(i=0;i<N;i++)
a=(Employee[i].salary<Employee[i+1].salary)?Employee[i].salary:Employee[i+1].salary;
printf("min=%d\n",a);
return 0;
}
main()
{
input(); /*调用input()函数*/
output(); /*调用output()函数*/
max(); /*调用max()函数*/
min(); /*调用min()函数*/
getchar();
}


IP属地:广西1楼2018-01-10 11:13回复