Didn't know that. I've experienced that with C++ names like cout or cin, but the GNU compiler has always let me use things out of <clibrary> (corresponding to <library.h>) without specifying the...
Type: Posts; User: zzzaaahhh
Didn't know that. I've experienced that with C++ names like cout or cin, but the GNU compiler has always let me use things out of <clibrary> (corresponding to <library.h>) without specifying the...
Yay, the board is working!
Kudos to sang-drax, for working SMART as opposed to hard! Congrats.
quzah, C++ vs C actually did make a little difference in shaving some characters off:
1) for...
The idea of when to use pointers with functions:
a) When you call a function and feed it variables as arguments, the function makes COPIES of the variables for its own use. So if you try to have...
Suppose that when you divide an integer n by a divisor d, you get the quotient q with remainder r: n = qd + r.
Then the operations / and % will give the results: n/d == q, n%d == r. So, if n%d...
Ok, readability is not a criterion for the contest. But if/when you do post the winners, can you ask the winners to decompress & comment them?
Also, you didn't mention whether there would be any...
This looks like a cool contest! I hope you will post the winning programs, which should be very instructive. Related to which, can I suggest a slight change in the rules? For people to be able to...
The numerical recipes in C book (http://www.nr.com) contains an extensive chapter on finding roots (chapter 9), with code for a variety of methods, as well as recommendations for shapes of curves...
It works perfectly for me. In order to get it to compile without warnings, I had to change the function prototype & definition to include void as sandman did, and include a return 0; at the end of...
I see this on XP and NT, IE6 & Netscape7. But I've noticed that it goes away if I forbid any scripts to run.
One thing that's useful in these sorts of situations is to try to say in words what you would do to figure this out.
You have successfully written code to get a (nonnegative) number from the user....
To be fair, he did apply code tags when told to, and did reindent when told to. So it's not that he hasn't been listening. It's that he hasn't been understanding. And he hasn't been understanding...
At the top of the home page for each of the boards, there's a bar indicating how many pages of threads there are. Sometimes, the bar displays only 40 blocks. But at other times, it displays like...
Rather than nested ifs, I think it will read easier to test yDiff1 and yDiff2 together. In other words, I think
if (absyDiff1 < TINY) {
if (absyDiff2 < TINY) {
do something 1...
Just FYI on evaluating the factorial of nonintegral arguments: the factorial function is just a special case of the gamma function, which is studied in courses on complex analysis. The definition...
You could just declare two fixed arrays of large enough size, like 100 cells each. That's not so expensive, and it more than exceeds the maximum row of Pascal's triangle that can be accurately...
The b is a variable. The code
bonus b=10;
is equivalent to
bonus b; /* defines b as a variable, of type bonus */
Well, just calculate the row first, before printing it out.
You could have two arrays of int, oldrow & newrow.
Initialize newrow with the first row of pascal's triangle, and initialize some...
D'oh! Should have known it was failing to ungetch something from the supposedly missing parentheses and carriage return. It works perfectly now. You guys are the best. Thanks!
Some observations:
What happens if yDiff2 and yDiff1 are BOTH tiny? Say yDiff1 = 0.00014, yDiff2 = -0.00007. Then
in the following code, |yDiff1-yDiff2| = 0.00021 > 0.0002, and you will not...
Hi, all. I am reading through the Kernighan/Ritchie 2nd edition of "The C Programming Language", and ran into trouble in chapter 5.12 (pp 123-125), where they write a program to translate complex...
This is not a programming answer, but more a philosophy consideration--amount of time you've had the program is not the fairest cutoff for when to cutoff trial usage. If you download something, use...
That's a better explanation that what I gave elad.
But just in case it's not clear that your disagreement is with my explanation and not with stilwell's code, I do want to emphasize that the code...
You can certainly end with
else if (y==10) r = 10;
That's perfectly good code. The only reason I wrote
else /* y==10 */ r=10; //the stuff in between /* */ is a comment
The basic idea of recursion is that you try to break down a big problem into similar but smaller subproblems.
In turn, each similar smaller subproblem is broken down into similar, even smaller...
That's a great observation--you don't even need a month variable, since you can just use 12*y for the number of months. That makes the "if" part even simpler.
If you put all the output at the...