yanghui triangle

W

winfield301

how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
.........................
 
V

Vladimir S. Oka

(e-mail address removed) opined:
how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................

In ISO Standard C, it's fairly easy:

#include <stdio.h>

int main(void)
{
printf("1\n");
printf("1 1\n");
printf("1 2 1\n");
printf("1 3 3 1\n");
printf("1 4 6 4 1\n");
printf("1 5 10 10 5 1\n);
printf("........................\n");

return 0;
}

Or did you mean algorithmically? In which case:

- this is a wrong group, try comp.programming
- a fee is chargeable for doing homeworks

--
BR, Vladimir

I guess I've been wrong all my life, but so have billions of
other people... Certainty is just an emotion.
-- Hal Clement
 
S

santosh

how to print the follow one:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
........................

printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");
 
V

Vladimir S. Oka

santosh opined:
printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");

Sorry, this does not work as OP wants. Mind the spacing. ;-)

--
BR, Vladimir

OCCAM'S ERASER:
The philosophical principle that even the simplest
solution is bound to have something wrong with it.
 
S

santosh

Vladimir said:
santosh opined:

printf("1\n1\t1\n1\t2\t1\n1\t3\t3\t1\n1\t4\t6\t4\t1\n1\t5\t10\t10\t5\t1\n");

Sorry, this does not work as OP wants. Mind the spacing. ;-)

You're right. Didn't read close enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top