结构体求助
为什么输出会是三个0呢???无法理解#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct student
{char name;
int age;
float score;
}ST;
int main ()
{ST stu[]={{"张三",18,81},{"王四",19,90},{"小二",21,93}};
strcpy(stu.name,"张三");
strcpy(stu.name,"王四");
strcpy(stu.name,"小二");
int i;
int j;
int n=3;
for (i=1;i<=3;i++)
{for (j=1;j<n-1-1;j++)
{if (stu.score>stu.score);
ST S;
S=stu;
stu=stu;
stu=S;
}
}
//输出
for (i=1;i<=3;i++)
printf("%d\n",stu.score);
getchar();
return 0;} 本帖最后由 风过无痕1989 于 2020-12-30 13:39 编辑
。。。 本帖最后由 jackz007 于 2020-12-30 01:55 编辑
用 "%d" 去显示一个浮点数还能不是 0 ?
typedef struct student {
char name;
int age;
float score ;
} ST;
. . . . . .
printf("%d\n" , stu[ i ] . score) ; {:10_266:} 风过无痕1989 发表于 2020-12-30 01:40
谢谢,发现冒泡排序也写错了 RRROLE 发表于 2020-12-30 12:07
谢谢,发现冒泡排序也写错了
那本来就是你自己的程序,你的问题是为什么输出三个0 !
现在也没有意义了
页:
[1]