# simple display problem??

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
hi,
In my array
\$arr=

i want to display output like
10
20
30
40
10+20
10+30
10+40
20+30
20+40
30+40
10+20+30
10+20+40
20+30+40
10+20+30+40

How to display output like this??
Can You please give me sample code??

## Re: simple display problem??

.oO(amit)

different solutions posted with code examples. You should learn to read
and understand such code snippets, so you can adjust them to your needs.

Micha

## Re: simple display problem??

In my old thread i was thinking as non-repeated combination.but it
takes huge time for processing as numbers in array increase from 20 to
50  i.e. array length more than 50

So i am looking for this type of looping solution.

## Re: simple display problem??

\$arr = array(10,20,30,40);
\$count=3Dcount(\$arr);
for (\$i=3D0;\$i<=3D\$count;\$i++)
{
echo \$arr[\$i]."<br>";
for(\$j=3D\$i+1;\$j<\$count;\$j++)
{
echo \$arr[\$i]."+".\$arr[\$j]."<br>";
}
}

i am looking for dynamic solution as array length varies
how to do this??

## Re: simple display problem??

amit wrote:

need to understand the answers and modify them as you need to.  Don't
expect us to do your homework for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

## Re: simple display problem??

amit wrote:

That won't solve anything - the compexity of the algorithm is at best
O(2^n), and there is no way to change that.

And no, don't expect me to explain you the concept of algorithmic
complexity.

--
----------------------------------
Iván Sánchez Ortega -ivan-algarroba-sanchezortega-punto-es-

http://ivan.sanchezortega.es
Proudly running Debian Linux with 2.6.29-1-amd64 kernel, KDE 3.5.10, and PHP
5.2.9-2 generating this signature.
Uptime: 14:49:38 up 5 days, 22:48,  5 users,  load average: 1.47, 0.98, 0.89

## Re: simple display problem??

Iván Sánchez Ortega wrote:

* looks around sheepishly and puts notepad away.

--
************************************
Remove the "x" from my email address
Scott Johnson
futureshockx@att.net
************************************

## Re: simple display problem??

Lots of information is available on the Net.  Here are a couple
Wikipedia articles:

<http://en.wikipedia.org/wiki/Analysis_of_algorithms
<http://en.wikipedia.org/wiki/Big_O_notation

You might also search for newsgroups covering algorithms.

--
~Curtis
\$email = str_replace('sig.invalid', 'gmail.com', \$from);

Anonymous (1984 IOCCC winner):