| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1648 人关注过本帖
标题:[求助] 为何不能输入分数?百思不得其解!
取消只看楼主 加入收藏
xiehongyou
Rank: 1
等 级:新手上路
帖 子:84
专家分:0
注 册:2004-8-29
收藏
 问题点数:0 回复次数:1 
[求助] 为何不能输入分数?百思不得其解!

错在哪#include "stdio.h" #define N 5 struct student { long num; char name[10]; int age; float score[7]; float total; } stu[N]; main() { int i,j,max,k; FILE *fp; for(i=0;i<N;i++) {printf("please input number!"); scanf("%ld",&stu[i].num); printf("please input name"); scanf("%s",stu[i].name); printf("please input age"); scanf("%d",&stu[i].age); for(j=0;j<7;j++) { printf("please input score!"); }scanf("%f",&stu[i].score[j]); stu[i].total=0.0; for(j=0;j<7;j++); stu[i].total+=stu[i].score[j]; }

if((fp=fopen("c:\\student.dat","wb+"))==NULL) {printf("file can not open!"); getch(); exit(0); } fwrite(stu,sizeof(struct student),N,fp); fread(stu,sizeof(struct student),N ,fp); max=stu[0].total; k=0; for(i=0;i<N;i++) if(max<stu[i].total) {max=stu[i].total;k=i;}

printf("%-6ld%-10s%-5d%6.2f\n",stu[k].num,stu[k].name,stu[k].age,stu[k].total); getch(); }里?输入里面的问题!但为何错了呢?

搜索更多相关主题的帖子: 输入 分数 百思不得其解 
2005-02-27 11:35
xiehongyou
Rank: 1
等 级:新手上路
帖 子:84
专家分:0
注 册:2004-8-29
收藏
得分:0 
for(j=0;j&lt;7;j++)
  {
   printf("please input score!");
  scanf("%f",&amp;stu[i].score[j]);
}
就是这一段有问题 ,前面的学号、姓名、年龄可以输入,到输入7课的分数就不行,这是为什么?
2005-02-27 14:17
快速回复:[求助] 为何不能输入分数?百思不得其解!
数据加载中...
 
   



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

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