不应该呀,提交之后不是红就是紫

B2054 求平均年龄

San__Shi @ 2025-01-10 22:24:53

#include <stdio.h>
int main()
{
    int n , i ,sum =  0;
    int arr[n];
    scanf("%d",&n);
    double ave ;
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        sum += arr[i];
    }
    ave =  sum*1.0 / n;
    printf("%.2lf",ave);
    return 0 ;
}

by zrl123456 @ 2025-01-10 22:26:49

int arr[n];
scanf("%d",&n);

???

scanf("%d",&n);
int arr[n];

by Eason0324 @ 2025-01-10 22:27:29

#include <stdio.h>
int main()
{
    int n , i ,sum =  0;
    int arr[109];
    scanf("%d",&n);
    double ave ;
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        sum += arr[i];
    }
    ave =  sum*1.0 / n;
    printf("%.2lf",ave);
    return 0 ;
}

试一下(n \to 109


|