运行结果名字为什么运行不出来啊
#include<stdio.h>#define N 5
struct student
{int number;
char name;
float score;
}student_1;
void main()
{int i;
struct student temp;
printf("请输入学生的基本信息\n");
for(i=0;i<N;i++)
{printf("学生学号为:");
scanf("%d",&student_1.number);
printf("\n");
printf("学生姓名为:");
scanf("%s",&student_1.name);
printf("\n");
printf("学生分数为:");
scanf("%f",&student_1.score);
printf("\n");}
int j,k;
for(i=0;i<N-1;i++)
{k=i;
for(j=i+1;j<N;j++)
if(student_1.score>student_1.score)
k=j;
temp=student_1;student_1=student_1;student_1=temp;
}
printf("排列后:\n");
for(i=0;i<N;i++)
printf("number is %d\nname is%s\nscore is %f\n",
输入姓名的那个scannf,后面的&和去掉,%s后面是地址即数组名
发代码请用代码格式,否则【i】会被吞掉
scanf("%s",student_1.name); sunrise085 发表于 2021-1-11 16:14
输入姓名的那个scannf,后面的&和去掉,%s后面是地址即数组名
发代码请用代码格式,否则【i】会被吞掉 ...
感谢大佬
页:
[1]