Barry Schwarz <sc******@dqel.comwrites:
On Tue, 01 Jul 2008 17:28:18 GMT, "Bill Cunningham" <no****@nspam.com>
wrote:
"Keith Thompson" <ks***@mib.orgwrote in message
news:lz************@stalkings.ghoti.net...
You're asking questions that are so elementary that you're practically
asking us to write the program for you.
Hmm.
Ok, here's an outline in English:
Keep track of the number of lines you've read and of the sum of the
numbers so far. Both start as 0 or 0.0.
For each line in the input file:
Get a floating-point number from the line.
Update the line counter and the sum.
Print the following on the output file:
The number you just read,
The sum of the numbers you've read so far,
The average of the numbers you've read so far
(the sum divided by the count).
You're talking about reading. I need to write the data
first. I've considered writing two functions to do this, one to
write and one to read. I need to start writing the data first. I
have a program that writes the single numbers and that's all.
I quote from your first post -
I have a row of values like such, placed in a text file by
fprintf.
I take it you are just lying to us for sport.
I'm having difficulty not reaching the same conclusion.
Bill, assuming you're not deliberately trolling, consider this. If
you had originally written something like this:
I have a text file with one floating-point number on each line.
I want to append the cumulative sum and the mean to each line.
For example, given this input:
10.50
10.25
10.00
10.75
11.00
I want to produce this output:
10.50 10.50 10.50
10.25 20.75 10.38
10.00 30.75 10.25
10.75 41.50 10.38
11.00 52.50 10.50
Now I can understand failing to ask a question clearly on the first
try. There's a great deal of skill in asking good questions.
But after multiple attempts to get you to state what you're trying to
do, you have repeatedly failed to significantly clarify anything. You
have evaded or ignored simple direct questions. I'm *still* not
certain that the above is an accurate description.
If you post a question, and somebody asks you a specific question
about your problem, then *answer the question*. If you're unwilling
to help us to understand what you're asking, we can't possibly help
you.
(And if you *are* deliberately trolling, then you're wasting a great
deal of the time of people who are simply trying to help someone
learn. If you find that kind of thing amusing, then I pity you.)
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"