当前位置: 代码迷 >> C语言 >> 菜鸟问话: 数据始终输不进去(Turbo C),?????
  详细解决方案

菜鸟问话: 数据始终输不进去(Turbo C),?????

热度:821   发布时间:2005-05-25 11:29:00.0
菜鸟问话: 数据始终输不进去(Turbo C),?????
main()
{   
struct student
{
char name[10];
float score[3];
};
int i,j;
struct student stud[5];
for(j=0;j<5;j++)
  {
   printf("\nname:");
   gets(stud[j].name);
   for(i=0;i<3;i++)
    {
      printf("\nscore%d:",i);
      scanf("%f",&stud[j].score[i]);
   }
     
  }
  for(j=0;j<5;j++)
   printf("\n%s,%f,%f,%f",stud[i].name,stud[j].score[0],stud[j].score[1],stud[j].score[2]);   
   getch();
}
搜索更多相关的解决方案: 问话  数据  Turbo  

----------------解决方案--------------------------------------------------------
main()
{   
struct student
{
char name[10];
float score[3];
};
int i,j;
float f;
struct student stud[5];
for(j=0;j<5;j++)
  {
   printf("\nname:");
   gets(stud[j].name);
   for(i=0;i<3;i++)
    {
      printf("\nscore%d:",i);
      scanf("%f",&f),stud[j].score[i]=f;
   }
     
  }
  for(j=0;j<5;j++)
   printf("\n%s,%f,%f,%f",stud[i].name,stud[j].score[0],stud[j].score[1],stud[j].score[2]);   
   getch();
}


----------------解决方案--------------------------------------------------------

#include <stdio.h> #include <conio.h>

int main() { struct student { char name[10]; float score[3]; }; int i,j; struct student stud[3]; for(j=0;j<3;j++) { printf("\nname:"); gets(stud[j].name); for(i=0;i<3;i++) { printf("\nscore%d:",i); scanf("%f",&stud[j].score[i]); fflush(stdin); } } for(j=0;j<3;j++) printf("\n%s,%f,%f,%f",stud[j].name,stud[j].score[0],stud[j].score[1],stud[j].score[2]); return 0;

}


----------------解决方案--------------------------------------------------------
你们见过这样的结构体么?
struct student
{
char name[10];
float score[3];
};

----------------解决方案--------------------------------------------------------