求助,C语言读取的问题
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define N 100
struct student
{
char name[N];
int total;
} ;
main()
{
int i,k,n;
char temp[N]={0};
struct student j[N];
printf("Please input the number of the students:");
scanf("%d",&n);
getchar();
printf("The name and the total scores are:\n");
struct student stu[n];
for(i=0;i<n;i++)
{
gets(stu[i].name);
scanf("%d",&stu[i].total);
getchar();
}
for(k=0;k<n-1;k++)
{
for(i=0;i<n-k-1;i++)
if(stu[i].total<stu[i+1].total)
{
j[i]=stu[i];
stu[i]=stu[i+1];
stu[i+1]=j[i];
}
}
for(i=0;i<n;i++)
{
if(stu[i].total==stu[i+1].total)
{
if(strcmp(stu[i].name,stu[i+1].name)>0)
{
j[i]=stu[i];
stu[i]=stu[i+1];
stu[i+1]=j[i];
}
}
}
for(i=0;i<n;i++)
{
printf("Name:%s\ntotal:%d\n\n",stu[i].name,stu[i].total);
}
system("pause");
}