Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. @zeus, It's better to use toupper. @obvious,...

    @zeus, It's better to use toupper.

    @obvious, Here's how I might do it, but it's not well-tested.

    Exposing the first letter is kind of strange. That's not usually how hangman works. Also, it...
  2. Your code is too much of a mess to fix. Scrap it...

    Your code is too much of a mess to fix.
    Scrap it and start anew.
    What you are trying to do is way simpler than you are making it.

    And you need to learn to use functions!
    And your indentation...
  3. Replies
    3
    Views
    70

    The error is that it's copying to elem instead of...

    The error is that it's copying to elem instead of p. Change it to p.

    BTW, "chapter 17" is not some kind of universal reference. There's a lot of books out there!
  4. Thread: EXE file

    by john.c
    Replies
    11
    Views
    177

    Okay. Whatever. Later.

    Okay. Whatever. Later.
  5. Thread: EXE file

    by john.c
    Replies
    11
    Views
    177

    Your original link contains 223702 characters....

    Your original link contains 223702 characters. Either you are posting an image incorrectly or there is something wrong with image posting on the site. I notice that it was a "png" image, but the...
  6. Replies
    32
    Views
    478

    I vote to not explain it to him. If he can't...

    I vote to not explain it to him. If he can't figure it out from what's been given so far then that's too bad. :tongue:
  7. Replies
    32
    Views
    478

    It's nice to see the simpler solution win! Maybe...

    It's nice to see the simpler solution win!
    Maybe a segmented sieve would work better?

    Anyway, it's bedtime for me.
    Later! :)
  8. Replies
    32
    Views
    478

    Something like this? #include ...

    Something like this?


    #include <stdio.h>

    typedef long long Int;

    Int find_lowest_prime_factor(Int x) {
    if (x % 2 == 0) return 2;
    for (Int d = 3; d * d <= x; d += 2)
  9. Replies
    32
    Views
    478

    I don't know. They probably give you a minute, so...

    I don't know. They probably give you a minute, so i guess it's fast enough.
    I wish I could fathom that Mathematica solution.
    It's mostly that Quotient line I can't figure out.
  10. Replies
    32
    Views
    478

    I found a C++ solution online that works. It was...

    I found a C++ solution online that works. It was written by a bad programmer but paring it down yields a 34 line program.


    #include <iostream>
    #include <vector>
    #include <cmath>

    typedef...
  11. Replies
    32
    Views
    478

    Can you post the link?

    Can you post the link?
  12. Replies
    32
    Views
    478

    That's interesting. I'll try to check that out...

    That's interesting. I'll try to check that out for higher values.
    BTW, to line up the first line, start with a period (or whatever character you think is most inconspicuous) in the first column.
    ...
  13. No. It does include the nul character, after the...

    No. It does include the nul character, after the newline. Otherwise we wouldn't be able to use strlen on it since strlen counts the number of characters until it hits the nul character.
  14. That code is garbage and unfinished. Why are you...

    That code is garbage and unfinished.
    Why are you interested in it?
  15. Replies
    32
    Views
    478

    Okay. It's good to have that fact-checked. (It...

    Okay. It's good to have that fact-checked. (It did seem low.)
  16. fgets includes the newline character in the...

    fgets includes the newline character in the string that it reads. Here's one way of getting rid of it. BTW, the size value passed to fgets should be the entire size of the array, which can be found...
  17. Replies
    32
    Views
    478

    I found it here:...

    I found it here: projecteuler-solutions/Solutions.md at master * luckytoilet/projecteuler-solutions * GitHub
    Who knows if it's correct, though. If it is then you only need 64-bit numbers, which is...
  18. Replies
    32
    Views
    478

    Well that's hardly fair! :) Still, it serves as...

    Well that's hardly fair! :)
    Still, it serves as a check: 2744233049300770

    Presumably there's a fairly easy way to solve this. I'm wondering how the given values for g(1000) and g(1000000) enter...
  19. Replies
    32
    Views
    478

    Not that anyone cares, but there is an error in...

    Not that anyone cares, but there is an error in the code above. Here is the fixed code and table. The last value (in parentheses) indicates how many values are in sequence from that point until the...
  20. Replies
    32
    Views
    478

    You need to find some kind of pattern. The...

    You need to find some kind of pattern. The results of this program look promising. Presumably the runs get larger and larger. Maybe you can take advantage of that.


    #include <stdio.h>

    typedef...
  21. Replies
    34
    Views
    355

    Or teaching bubble sort at all. Double,...

    Or teaching bubble sort at all.

    Double, double toil and trouble;
    File burn and data bubble.
    Eye of Knuth and n-squared sorts
    Code of newbs so full of warts.
  22. Replies
    12
    Views
    157

    Great points. I forgot all about the destructor...

    Great points. I forgot all about the destructor calls (when appropriate) and the non-binding nature of shrink_to_fit(). Just goes to show how memory management is pretty complicated.
    Thanks...
  23. Replies
    8
    Views
    213

    The linker knows nothing about .h files. The .c...

    The linker knows nothing about .h files.
    The .c files are turned into .o (object) files.
    The linker only deals with object files (and libraries of those).
    The object files contain missing...
  24. Replies
    12
    Views
    157

    If you stored a million ints in a vector and then...

    If you stored a million ints in a vector and then cleared it, it would be pretty arbitrary for the system to "deallocate" the memory since, as far as it knows, you may be about to fill it up again...
  25. Replies
    12
    Views
    157

    Exactly. There's the shrink_to_fit() method for...

    Exactly. There's the shrink_to_fit() method for actually returning memory back to the allocator (although it probably won't return it back to the operating system, since that's pretty much pointless).
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4