Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Reading lines from a file, eliminating CR and LF Date: Thu, 05 Jan 2017 08:24:19 -0800 Organization: None to speak of Lines: 32 Message-ID: References: <87ful7dlk5.fsf@bsb.me.uk> <04709823-a412-4700-9597-7e6282bf11de@googlegroups.com> <87a8bejhsp.fsf@bsb.me.uk> <48561015-9c83-48da-ba00-28fa3ebca81d@googlegroups.com> <87pok9ilpd.fsf@bsb.me.uk> <6466708f-c0ee-457d-b1e8-e7817949c410@googlegroups.com> <87wpecidvw.fsf@bsb.me.uk> <0ffc9b05-76c6-47ef-8508-44d70383c2aa@googlegroups.com> <87ful0i5rq.fsf@bsb.me.uk> <87lgurfqmt.fsf@bsb.me.uk> <424b6473-9d52-473f-abce-4de84994b566@googlegroups.com> <87a8b6n9h8.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="823e57597edb8da97e8f43b1b8c9fed4"; logging-data="8642"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QkBE++nwaYBQWDWAfQsdR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ACrx989M6V5ZhzMuiMHB5u9jk34= sha1:O07QxnZoMJXtw32kJbvMj8qiBYI= Xref: csiph.com comp.lang.c:101178 Alla _ writes: > On Wednesday, January 4, 2017 at 6:14:22 PM UTC+3, Ben Bacarisse wrote: >> Alla _ writes: [...] >> > It also would be interesting to scale up the third exercise to write a >> > program that computes the average of the differences of all numbers in >> > the line, which can contain any number of numerical values; and ignore >> > lines like the one I have thought of initially when doing exercise 2, >> > i.e. lines that can contain non-numerical characters anywhere within >> > the line. >> >> That would make a fine exercise 5, though I would not use average of >> differences simply because (if I understand the term) it requires an >> extra condition of the there being an even number of data items. But that >> could be the exercise 6. >> > Why have you suggested that taking an average of a set of numbers requires > that set to contain an even number of elements, if I have understood you > correctly? And the exercise 3 requires the program to compute the average > of differences. I sense some misunderstanding here ) It depends on what "average of differences" means. Given the sequence 10, 20, 40, 70, does the "average of differences" mean the average of 10, 20, and 30, or 10 and 30? If the latter, you need an even number of elements. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"