请问这个问题怎么解决

问题遇到的现象和发生背景

定义一个学生结构体类型student,包括4个字段,姓名、性别、年龄和成绩。然后在主函数中定义一个结构体数组(长度不超过1000),并输入每个元素的值,程序使用冒泡排序法将学生按照成绩从小到大的顺序排序,然后输出排序的结果。

问题相关代码,请勿粘贴截图
#include
#include
struct student {
    char name[21];
    char sex[7];
    int age;
    int score;
};
int main()
{
    int  n, i, j;
    printf("请输入学生数:(学生数量<10000)");
    scanf_s("%d", n);
    struct student stu[n], t;
    for (i = 0; i < n; i++)
    {
        printf("请输入第%d个学生:", n + 1);
        scanf_s("%s%s%d%d", &stu[i].name, &stu[i].sex, &stu[i].age, &stu[i].score);
    }
    for (i = 0; i < n; i++)
    {
        for (j = n - 1; j > i; j--)
        {
            if (stu[j - 1].score > stu[j].score)
            {
                t = stu[j];
                stu[j] = stu[j - 1];
                stu[j - 1] = t;
            }
        }
        printf("%s  %s  %d  %d\n", stu[i].name, stu[i].sex, stu[i].score);
    }
    return 0;
}


运行结果及报错内容
严重性    代码    说明    项目    文件    行    禁止显示状态
错误    C2131    表达式的计算结果不是常数    ConsoleApplication3    c:\users\jd\source\repos\consoleapplication3\consoleapplication3\consoleapplication3.cpp    341    
严重性    代码    说明    项目    文件    行    禁止显示状态
错误    C3863    不可指定数组类型“student [n]”    ConsoleApplication3    c:\users\jd\source\repos\consoleapplication3\consoleapplication3\consoleapplication3.cpp    354    


img


修改见注释
有问题可以回复

#include<stdio.h>
#define max 10000
struct student
{
    char name[21];
    char sex[7];
    int age;
    int score;
};
int main()
{
    int  n, i, j;
    printf("请输入学生数:(学生数量<%d)",max);
    scanf_s("%d", &n);//加了&
    struct student stu[max], t;
    for (i = 0; i < n; i++)
    {
        printf("请输入第%d个学生:", i + 1);//改成i+1
        scanf_s("%s%s%d%d", stu[i].name,20, stu[i].sex,6, &stu[i].age, &stu[i].score);//输入字符串不用&,后面跟字符串长度 
    }
    for (i = 0; i < n - 1 ; i++)//冒泡排序 
    {
        for (j = 0; j <n - i - 1 ; j++)
        {
            if (stu[j].score > stu[ j + 1 ].score)
            {
                t = stu[j];
                stu[j] = stu[j + 1];
                stu[j + 1] = t;
            }
        }
        for (i = 0; i < n; i++)//遍历输出 
        {
            printf("%s  %s  %d  %d\n", stu[i].name, stu[i].sex, stu[i].age, stu[i].score);
        }
    }
    return 0;
}

1.首先,如果你是c语言,那么你需要头文件,

2.第13行,改正后应是:

scanf_s("%d", &n);

读入整数要加取地址符,常识问题。

3.第17行,改正后应是:

printf("请输入第%d个学生:", i + 1);

i+1代表当前读入学生的序号。

4.第18行,改正后应是:

scanf("%s%s%d%d", stu[i].name, stu[i].sex, &stu[i].age, &stu[i].score);

读入字符串不加取地址符,scanf_s会爆栈。

5.第31行,改正后应是:

printf("%s  %s  %d  %d\n", stu[i].name, stu[i].sex, stu[i].age, stu[i].score);

你printf里要输出两个整数,为什么你只代了一个参数?