发布网友 发布时间:2022-04-20 09:33
共1个回答
热心网友 时间:2023-09-25 22:05
#include <stdio.h>
typedef struct Cash {
char name[2];
float price;
int base_hour;
int add_hour;
float base_cash;
float add_cash;
float cash;
};
int main()
{
struct Cash Person[4];
int i = 0;
for(i = 0; i < 4; i++)
{
printf("Detail information (%d):\n", i + 1);
puts("姓名:");
scanf("%s", &Person[i].name);
puts("费用:");
scanf("%f", &Person[i].price);
puts("基本工作时间:");
scanf("%d", &Person[i].base_hour);
puts("额外工作时间:");
Person[i].add_hour = Person[i].base_hour - 40;
printf("%d\n", Person[i].add_hour);
puts("基本工资:");
scanf("%f", &Person[i].base_cash);
puts("超时工资:");
Person[i].add_cash = (Person[i].add_hour <= 0)?0 : Person[i].base_cash * 1.5;
printf("%f\n", Person[i].add_cash);
puts("总工资:");
Person[i].cash = Person[i].base_cash + Person[i].add_cash;
printf("%f\n", Person[i].cash);
}
for (i = 0; i < 4; i++)
{
printf ("姓名\t费用\t工作时间\t基本工资\t超时工资\t总工资\n");
printf ("%s\t%f\t%d\t%f\t%f\t%f\n",
Person[i].name, Person[i].price, Person[i].base_hour,
Person[i].add_cash, Person[i].add_cash, Person[i].cash);
}
return 0;
}