今天时间太晚了根本没时间仔细看解决bug了
#include <stdio.h>
struct worker
{
char num[10];
char name[10];
float salary;
};
int main()
{
struct worker w[100], * p = w;
int i, n=0;
float sum = 0;
printf("Please input the number of workers:");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("Please input %th workers information(workernumber: name: salary:)\n", i + 1);
scanf("%s%s%f", p->num, p->name, p->salary);
sum += p->salary;
p++;
}
printf("The average salary is %.2f\n", sum / n);
printf("The information of whose salary low than 2000.0:\n");
p = w;
printf("The number of work\t name\tsalary\n");
for (i = 0; i < n; i++)
{
if (p->salary < 2000.0)
printf("%s\t%s\t%.2f\n", p->num, p->name, p->salary);
p++;
}
while (1);
return 0;
}