Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    129

    Going by the names, they seem to be constants not...

    Going by the names, they seem to be constants not variables. We would normally define those with defines:


    #define BOOL unsigned char
    #define FALSE 0
    #define TRUE 1

    or possibly as an enum:
  2. Replies
    17
    Views
    577

    How high are the inputs likely to go? With...

    How high are the inputs likely to go?

    With inputs of 100 100 100 100 there are four hundred million unique potential calls (since last is also a parameter and has 4 values). That's a lot of...
  3. Replies
    3
    Views
    151

    The simplest way is the following. This prepends...

    The simplest way is the following. This prepends new items, so printing the list will yield the data in the reverse order that it was added.


    #include <stdio.h>
    #include <stdlib.h>

    typedef...
  4. If you want your code to be understood...

    If you want your code to be understood internationally then all of your identifiers (variable and function names, etc.) should be in English. Output text can be in Polish but it would be nice to...
  5. Replies
    17
    Views
    577

    Your English is excellent. Anyone could have...

    Your English is excellent. Anyone could have misspoke and said combinatronics, especially in a computer context. Combinatorics is a strange word. :redface:
  6. Replies
    17
    Views
    577

    hamster_nz: you've made a typo since the...

    hamster_nz: you've made a typo since the "minimum( s, e )" should of course be maximum.

    iloverecursion: "Necklace" should really mean a circle. But if those examples are from the problem...
  7. Replies
    17
    Views
    577

    This is interesting. You are assuming that the...

    This is interesting. You are assuming that the word "necklace" means that we are creating a circle, which makes sense but I didn't think of it that way. I thought of it as a line. The instructions do...
  8. Replies
    17
    Views
    577

    This seems pretty fast. It's based on my analysis...

    This seems pretty fast. It's based on my analysis that an optimal string can always be created with all z's together and all s's together. The only change from a pure brute force method is the two...
  9. Replies
    17
    Views
    577

    Do you have example input/output? Post it. ...

    Do you have example input/output? Post it.

    Problems with second solution:
    In main:
    You need to init k to 0.
    val, max_sol, max_count, and j are not used.

    Input of 3, 2, 4, 3 should...
  10. Replies
    17
    Views
    577

    The correct term is "combinatorics". :) Post...

    The correct term is "combinatorics". :)
    Post your brute force solution.
  11. Replies
    8
    Views
    363

    Thanks thmm. That's interesting. gawiellus,...

    Thanks thmm. That's interesting.

    gawiellus, nobody asked you to compare slowo[0] to 0x1a. It is not common for an actual 0x1a to be in the file data. That was just an experiment.

    How about:
    ...
  12. Replies
    8
    Views
    363

    It would be interesting if someone on Windows...

    It would be interesting if someone on Windows could test the following which creates a text file called ctrlz.txt. Once it's created, try "typing" it out in the console with the command type...
  13. Replies
    8
    Views
    363

    I think on Windows you need to not only enter...

    I think on Windows you need to not only enter ctrl-Z as the first "character" on a new line but you also need to press Enter after it.
    If I recall, hex 0x1a (which, being decimal 26, is ctrl-Z) is...
  14. Replies
    10
    Views
    462

    aghast has suggested another possibility, to read...

    aghast has suggested another possibility, to read the entire file into a single allocated buffer, count the newlines, allocate the line pointers, point them to the beginnings of the lines and replace...
  15. Replies
    3
    Views
    313

    Although I do not believe either conforms to any...

    Although I do not believe either conforms to any particular dietary laws, I do believe that they are essentially equivalent in the given context. However, you should get a warning about missing...
  16. Replies
    10
    Views
    462

    Here's an example of using fgets. It's still...

    Here's an example of using fgets. It's still inefficient to allocate the line pointers one-at-a-time, though. To improve that you would store not just the number of lines currently stored but a...
  17. Replies
    10
    Views
    462

    This is a meaningless statement: ...

    This is a meaningless statement:


    *(stringbuild + strlen(stringbuild)) = '\0';

    If it works, then there must already be a '\0' character at that exact position, otherwise strlen wouldn't know...
  18. Another possible mistaken implementation is...

    Another possible mistaken implementation is leaving out the braces to delimit the outer "if" block like this:


    if (optype == 'L')
    if (a < b) {blah-blah}
    else
    if (a > b)...
  19. For instance, if you mistakenly implemented it...

    For instance, if you mistakenly implemented it like:


    if (optype == 'L' && a < b) {blah-blah}
    else if (a > b) {blah-blah}

    Then if optype == 'L' is true and a < b is false, the...
  20. Yeah, now that I read this again, it doesn't make...

    Yeah, now that I read this again, it doesn't make sense. Maybe you implemented it wrong and that somehow led to a longer runtime. For instance, it seems that your code (2) above should be more like...
  21. I don't fully understand, but perhaps you could...

    I don't fully understand, but perhaps you could just swap(a, b) before the loop under some condition. Does that make sense?
  22. Replies
    3
    Views
    325

    You should open both files in binary mode "rb"...

    You should open both files in binary mode "rb" and "wb".

    Key (a.k.a., K in encrypt) doesn't make sense. It's just an index mod strlen(KWORD). Why are you passing it in? Why would it start at 'K'?...
  23. Replies
    3
    Views
    285

    You can read the number as a string and process...

    You can read the number as a string and process it that way.
    You can convert the integer to a string and process it that way.
    You can use the mod operator (% 10) to strip off the last digit one at...
  24. Replies
    2
    Views
    227

    I assume you are calling it without an argument,...

    I assume you are calling it without an argument, which would cause undefined behaviour. You need to supply an argument. To supply one that starts with a whitespace character you would need to use...
  25. Replies
    4
    Views
    343

    You say you can't use a "data structure", but if...

    You say you can't use a "data structure", but if you can use an array then this is a good ten times faster.


    #include <stdio.h>

    #define MAXNUM 10000000

    int xp[MAXNUM + 1];

    int main() {
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4