>>hi all,
>>>
>>can u give me the code to create a Pascal's Triangle....... .... and
>>yes, it should work
>If you can make this print one more row correctly, I will be impressed.
>
1 12 66 220 495 792 924 792 495 220 66 12 1
>
Prepare to be impressed.
I started writing a program that would find the (n+1)th row by
evaluating only the n-th row as an array, but I expected one or two
of the quick thinkers on the list to (a.) correct the errors in my first
program pointing out more problems than there were expressions, and (b.)
post some solution that renders the correct result without any arbitrary
limits, formatting the output so that lines are centered, and all in a
single line of code with no assignments :-)
>>GUPTAJI wrote:
>>>hi all,
>>>>
>>>can u give me the code to create a Pascal's Triangle....... .... and
>>>yes, it should work
>>If you can make this print one more row correctly, I will be impressed.
>>
>1 12 66 220 495 792 924 792 495 220 66 12 1
>>
>Prepare to be impressed.
>
I started writing a program ...
My immediate reaction was to post a program that generates a Sierpinski
triangle, leaving the filling in of the actual numbers as an exercise for
the reader. But apathy prevailed.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
"jmcgill" <jmcgill@email. arizona.eduwrot e in message
news:Hj1Vg.755$ rS.421@fed1read 05...
I started writing a program
I've done that!
but I expected one or two of the quick thinkers on the list to
(a.) correct the errors in my first program
(b.) post some solution
And where did you send the money? I'm not the quickest of "the thinkers on
list" but I waited by the mailbox and my box of money never came.
Of course, I always wait by the mailbox for my box of money, and your's not
coming was just one more daily disappointment. I bet you are not your
father's favorite son...
The solution is right here. Please send the money NOW. If you don't The
Solution will be deleted from my hard drive! I am SERIOUS! Send money
NOW!!!!
>hi all,
>>
>can u give me the code to create a Pascal's Triangle....... .... and
>yes, it should work
>
If you can make this print one more row correctly, I will be impressed.
>
>
#include <stdio.h>
>
unsigned long factorial(unsig ned long a){
return a == 0UL ? 1UL : a * factorial(a-1UL);
}
>
int main(int argc, char **argv){
>
unsigned long row, num, val, fact;
>
for(row=0UL; row < 13UL; row++){
for(num=0UL; num <= row; num++){
val =
factorial(row) / (factorial(num) * factorial(row-num));
printf("%lu ", val);
}
printf("\n");
}
>
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void)
{
unsigned long r, n, v;
double f;
/*
* Printing one more row correctly, using floating
* point technology.
*/
for (r = 0; r < 14; puts(""), r++)
for (n = 0; n <= r; printf("%.0f ", exp(f)), n++)
for (v = f = 0; v < n; v++)
f += log(r - v) - log(v + 1);
return 0;
}
"jmcgill" <jmcgill@email. arizona.eduwrot e in message
news:Hj1Vg.755$ rS.421@fed1read 05...
>I started writing a program
>
I've done that!
>
>but I expected one or two of the quick thinkers on the list to
>(a.) correct the errors in my first program
>(b.) post some solution
>
And where did you send the money? I'm not the quickest of "the thinkers on
list" but I waited by the mailbox and my box of money never came.
>
<snip>
You may not have noticed, but jmcgill wasn't actually the OP
requesting help with a homework problem, and I'm thinking
the expectation was a little jovial.
Comment