Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #126438

Re: C program with 2 For loops

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: C program with 2 For loops
Date 2018-02-08 15:02 +0000
Organization A noiseless patient Spider
Message-ID <871shvfrs9.fsf@bsb.me.uk> (permalink)
References <5a7bafd4$0$710$14726298@news.sunsite.dk> <p5gbfd$2kg$1@dont-email.me>

Show all headers | View raw


ais523 <ais523@nethack4.org> writes:

> arnuld wrote:
>> AIM:  To solve the problem given down
>> PROBLM: Am I missing something ?  Was it really that easy to program in 
>> C ?
>>
>> PROBLM: Input is an integer array A. Return an integer array B such that 
>> B[i] = product of all elements of A except A[i]
<snip>
> The likely point of the problem, though, is that there's a cleverer way
> to do it that runs faster (although the one I'm thinking of is likely to
> be less general because it has even more severe issues with
> overflows).

I am pretty sure I know what you are thinking of but it's not an
entirely trivial solution.  And since in the general case the products
grow in magnitude very fast, it may not even be worth the extra time
taken to write it because the largest array that can be processed is
going to be quite small!

Still it's an interesting problem so I've written it anyway.  I won't
post it unless anyone asks (since it's a spoiler) but I get the feeling
it can be done more neatly.

-- 
Ben.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

C program with 2 For loops arnuld <sunrise@invalid.address> - 2018-02-08 02:03 +0000
  Re: C program with 2 For loops ais523 <ais523@nethack4.org> - 2018-02-08 02:08 +0000
    Re: C program with 2 For loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-08 15:02 +0000
  Re: C program with 2 For loops Keith Thompson <kst-u@mib.org> - 2018-02-07 18:32 -0800
  Re: C program with 2 For loops Barry Schwarz <schwarzb@dqel.com> - 2018-02-07 18:36 -0800
    Re: C program with 2 For loops Barry Schwarz <schwarzb@dqel.com> - 2018-02-08 00:52 -0800
  Re: C program with 2 For loops "James R. Kuyper" <jameskuyper@verizon.net> - 2018-02-08 10:35 -0500
    Re: C program with 2 For loops Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-02-08 18:23 +0000
  Re: C program with 2 For loops Clive Arthur <cliveta@nowaytoday.co.uk> - 2018-02-09 13:21 +0000
    Re: C program with 2 For loops williammcnicol@gmail.com - 2018-02-09 05:59 -0800
      Re: C program with 2 For loops Clive Arthur <cliveta@nowaytoday.co.uk> - 2018-02-09 14:39 +0000
      Re: C program with 2 For loops James Kuyper <jameskuyper@verizon.net> - 2018-02-09 10:41 -0500
    Re: C program with 2 For loops Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-02-09 17:41 +0000
      Re: C program with 2 For loops James Kuyper <jameskuyper@verizon.net> - 2018-02-09 12:56 -0500
        Re: C program with 2 For loops Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-02-10 07:49 +0000
  C program with 2 For loops asetofsymbols@gmail.com - 2018-02-12 11:14 -0800
    C program with 2 For loops asetofsymbols@gmail.com - 2018-02-12 12:03 -0800
      C program with 2 For loops asetofsymbols@gmail.com - 2018-02-12 12:15 -0800
        C program with 2 For loops Chad <cdalten@gmail.com> - 2018-02-12 17:11 -0800

csiph-web