| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 908 人关注过本帖
标题:文件处理老是不对,为什么?
只看楼主 加入收藏
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
收藏
得分:0 
以下是引用azzbcc在2013-3-29 15:06:29的发言:

你的,那个站点记录不是连续的,不能那样直接录入数组的,回导致 后面的amount值出错
 
totalamt未初始化
 
printf函数里面 用这个 %[] ?

我数了一下,里面有30个站,因此我把scanf inprice文件的代码改成:
for (x=1; x<31; x++)
   {
   fscanf(inprice, "%d;%[^;];%lf\n", &stop, location, &price[x]);
   }
还是不能运行。到底是哪里出错呢?
2013-03-29 22:56
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
收藏
得分:0 
以下是引用azzbcc在2013-3-29 15:06:29的发言:

你的,那个站点记录不是连续的,不能那样直接录入数组的,回导致 后面的amount值出错
 
totalamt未初始化
 
printf函数里面 用这个 %[] ?

程序要求里说明:You can assume that there will be at most 200 stops. You can also assume that the stop numbers are always in order from smallest to biggest but that some stop numbers may not be currently used and thus do not exist in the file.
编程者可假设有200个站点,站点是按照从小到大排列,有些站点目前未使用,因此不在locations.txt中。
2013-03-29 23:03
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:0 
以下是引用winglesswu在2013-3-29 23:03:37的发言:


程序要求里说明:You can assume that there will be at most 200 stops. You can also assume that the stop numbers are always in order from smallest to biggest but that some stop numbers may not be currently used and thus do not exist in the file.
编程者可假设有200个站点,站点是按照从小到大排列,有些站点目前未使用,因此不在locations.txt中。


应该改把 第 n个站点的数据,存入 price[n]中、、


[fly]存在即是合理[/fly]
2013-03-30 00:03
快速回复:文件处理老是不对,为什么?
数据加载中...
 
   



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

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