发布网友 发布时间:2022-04-21 19:45
共1个回答
热心网友 时间:2022-05-13 05:36
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
float *middle,*last,*daily;
float *result;
int *times;
printf("input n: ");
scanf("%d",&n);
middle=(float*)malloc(n*sizeof(float));
last=(float *)malloc(n*sizeof(float));
daily=(float *)malloc(n*sizeof(float));
result=(float *)malloc(n*sizeof(float));
times=(int *)malloc(n*sizeof(int));
int i=0;
for(;i<n;i++)
{
scanf("%f%f%f%d",&daily[i],&middle[i],&last[i],×[i]);
daily[i]=daily[i]-10*times[i];
if(daily[i]<=0) daily[i]=0;
result[i]=daily[i]*0.1+middle[i]*0.3+last[i]*0.6;
if(times[i]>=3)
result[i]=0;
}
for(i=0;i<n;i++)
printf("%6.1f\n",result[i]);
return 0;
}