标题:编译语法没错误 输出不正确 哪位大神指点一下 谢谢
取消只看楼主
天下天下
Rank: 2
等 级:论坛游民
帖 子:62
专家分:15
注 册:2013-10-14
结帖率:66.67%
 问题点数:0 回复次数:0 
编译语法没错误 输出不正确 哪位大神指点一下 谢谢
源程序:
#include<stdio.h>
#include<stdlib.h>

int main(void)

{
struct st
{
int age ;
char name[20] ;
float score ;

};

int b ;
scanf("%d",&b);

struct st *a[50];
int i = 0 ;

for(i ; i<b ;i++)
{
a[i] = (struct st *) malloc(sizeof(struct st));
printf("please input age : ");
scanf("%d",a[i]->age);
printf("please input name : ");
scanf("%s",a[i]->name);
printf("please input score : ");
scanf("%.1f",a[i]->score);   
printf("\n");
}

for(i = 0 ;i<b ;i++)
{
printf("%d %s %f\n",a[i]->age, a[i]->name, a[i]->score);
}

return 0 ;
}

输出如下:
3
please input age : 22
please input name : dgrg
please input score : 99

please input age : please input name : bddfb
please input score : 99

please input age : please input name : gbdfb
please input score : 66

11492368 dgrg 18305179148001886000000000.000000
11473936 bddfb 0.000000
11473936 gbdfb 0.000000

--------------------------------
Process exited after 19.25 seconds with return value 0
请按任意键继续. . .
搜索更多相关主题的帖子: please input name age score 
2020-03-28 10:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-500670-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.224869 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved