When the program runs, the first line is input, but the line feed should directly output the result

CSDN Q & A 2022-01-15 02:36:45

The procedural requirements are : Input common n+1 That's ok . first line , An integer n, It means that there is a total of n A student . Next  n  In line , The first i+1 Lines indicate numbers  i  Student achievement of , Contains three integers  a ,b ,c, Every two integers are separated by a space .
#include<stdio.h>
int main()
{
int n,i,j,b[n][3],t;
float a[n];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&b[i][1],&b[i][2],&b[i][3]);
a[i]=b[i][1]*0.2+b[i][2]*0.2+b[i][3]*0.6;
}
for(j=1;j<n;j++)
for(i=0;i<j;i++)
if(a[i]<a[j])
{
t=a[i];a[i]=a[j];a[j]=t;
}
for(i=0;i<n;i++)
printf("%.1f\n",a[i]);
}

img

img


thank
Similar articles