Like Tree1Likes

Almost Daily Contest #4

This is a discussion on Almost Daily Contest #4 within the Contests Board forums, part of the Community Boards category; Thanks Got code near working with STL, wont be shortest but i'll be happy as long as it works hehe...

  1. #31
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    Thanks
    Got code near working with STL, wont be shortest but i'll be happy as long as it works hehe

  2. #32
    Registered User
    Join Date
    May 2003
    Posts
    148
    Originally posted by -KEN-
    Change your files from a .cpp extensiopn to a .c extension. Problem solved.
    No,not 100% correct.
    6.3.2.2.
    Each argument shall have a type such that its value may be assigned to an object with the unqualified
    version of the type of its corresponding parameter.
    The types char ** and const char ** are both pointers to unqualified types that are not the same type, they are not compatible types. Therefore, a call with an argument of type char** corresponding to a parameter of type const char ** is not allowed. Therefore, the constraint given in Section 6.3.2.2 is violated, and a diagnostic message must be produced.

    <from Expert C Programming - Peter van der Linden>

  3. #33
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: Almost Daily Contest #4

    Originally posted by Prelude
    For Everyone
    That finds any occurance of 'word' in the table 'tab'. The function will return 0 if the word does not exist in the table and 1 if the word is found. The two-dimensional indices of the word will be placed in the array 'indices'.
    And what if it occurs more than once?

    [edit]
    Furthermore, what assumptions are we given? Are we using your example of the provided 'indicies' array, and 'tab'? Or are we to assume there is an arbitrary length of either?

    If the latter, your problem is unsolvable. The reason being, unless you have a way to specificly tell us we are at the end of the 'tab' array, we will never know where the end is.

    One could try and assume, assuming that every element in 'indicies' has been preset to -1. However, if that isn't a given either, then again, your problem is not solvable.

    You haven't defined the problem well enough.
    [/edit]

    Quzah.
    Last edited by quzah; 08-25-2003 at 01:34 AM.
    Hope is the first step on the road to disappointment.

  4. #34
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    And what if it occurs more than once?
    I made my program so that if there are more than 1 word, only the first one found is stored. Since she hasn't defined any behaviour for more than 1 occurance of the word, I take it that 1 word is all we're going to find.

    Are we using your example of the provided 'indicies' array, and 'tab'? Or are we to assume there is an arbitrary length of either?
    The length of Indices have to be at least as large as the length of the word * 2, or you're unable to store the result. I guess that can be assumed. As for the size of Tab she mentioned that a quadratic form can be assumed (page 2), but it isn't hard to get the real dimensions manually (notice the empty string at the end?).

    unless you have a way to specificly tell us we are at the end of the 'tab' array, we will never know where the end is.
    You can tell this. There are methods for calculating the length of a string, and to find an empty string ( "" ) in an array of strings.

    One could try and assume, assuming that every element in 'indicies' has been preset to -1
    I assumed this.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #35
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Magos
    You can tell this. There are methods for calculating the length of a string, and to find an empty string ( "" ) in an array of strings.
    No you can't. What I was talking about is this:
    Code:
    char *foo[] =
    {
        "you",
        "cannot",
        "tell",
        "how",
        "many",
        "of",
        "these",
        "there",
        "are",
        "if",
        "I",
        "do",
        "not",
        "provide",
        "an",
        "empty",
        "string",
        "at",
        "the",
        "end"
    };
    There is no way to know how many strings are in this array. This holds true for the number of indices also. Unless you set them all to -1 before the function call, you cannot know how many there are with the function prototype given us.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #36
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >There is no way to know how many strings are in this array.
    In that array, yes. In my array there's an empty string as the last element that you can use to determine where to stop.

    >This holds true for the number of indices also.
    You can assume that the array is at least large enough to hold all of the necessary values and a terminating -1.
    My best code is written with the delete key.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Almost Daily Contest Details
    By dagdarian in forum Contests Board
    Replies: 4
    Last Post: 01-25-2005, 04:03 AM
  2. Almost Daily Contest Details
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 09-19-2004, 10:32 PM
  3. Almost Daily Contest #3
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 08-16-2003, 08:48 PM
  4. Almost Daily Contest #2
    By Prelude in forum Contests Board
    Replies: 37
    Last Post: 08-09-2003, 10:51 PM
  5. Almost Daily Contest #1
    By Prelude in forum Contests Board
    Replies: 32
    Last Post: 08-05-2003, 08:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21