Thread: A challange

  1. #31
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    And just a little history, "algorithm" derives from the name Al' Khwarizmi, the Islamic mathematician who wrote the first book (probably) of algebra.

    Also in the definition many would add: "...in finite time"

  2. #32
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Well, when I loose something, I give up finding it, and figure another way around, or if I really need it badly, I buy another one of it :P
    Anyways, algorithm is some advanced stuff, I guess. Leaving the advanced stuff for now :P
    Currently research OpenGL

  3. #33
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Akkernight View Post
    Well, when I loose something, I give up finding it, and figure another way around, or if I really need it badly, I buy another one of it :P
    Anyways, algorithm is some advanced stuff, I guess. Leaving the advanced stuff for now :P
    That's not going to work -- it is not physically possible to write a program without having an algorithm behind it. (Even Hello World has an algorithm behind it, although granted not much of one.) Every time Elysia (or I) asks for a flowchart, that's all that is -- do you have the algorithm in place so that you can even get started writing code.

  4. #34
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    ... If only I really understood what algorithm is :P saying that word to me, is like saying hbula bla bla, makes no sense :P
    But I can write a Hello World program, so I guess I do use algorithm, but got no idea what it is...? (I hope :P)
    Currently research OpenGL

  5. #35
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Once again, an algorithm is a step-by-step procedure which solves a problem in a finite amount of time.

    A simple step-by-step-procedure for the next problem you will have, reading my post: To see this post, first, you likely clicked refresh on your browser, then scrolled to the end of the page. Then you started reading from left to right since you've determined that the text is English. When you finished, you may or may not have thought about its contents before replying.

    When you do understand, then you've completed your task, understanding the word algorithm in a finite amount of time. At that point, you've completed an algorithm to understand the meaning of algorithm.


  6. #36
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Oh... Now I follow, kinda
    So my brain is an algorithm user... Strange, didn't even think I used it for anything :P
    Well, thanks for clearing that up ^^
    Currently research OpenGL

  7. #37
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Code:
    const char *pDay[] = {"Sunday", "Monday",
                    "Tuesday", "Wednesday",
                    "Thursday", "Friday",
                    "Saturday"};
    Quote Originally Posted by Elysia View Post
    Yep, that takes care of the bad practice part... But the code is still too complex to understand right away without digging into the code and I am not going to bother to.
    Nope, that's wrong. The correct way to use the const keyword in context of the originally posted code is as follows:

    Code:
    char *  const pDay[] = {"Sunday", "Monday",
    		"Tuesday", "Wednesday",
    		"Thursday", "Friday",
    		"Saturday"};
    Well, since you won't bother to dissect the code, you won't know whether or not my logic is flawed. Will you?

    Also, lint does not flag the pDay variable. It does flag a few other items but not pDay.

    Anyone who does not have access to lint and wishes to independently verify any of the statements made in this thread, you can use Splint the freeware equivalent of lint.

    Finally, Elysia, you should send your "bad practices" to the Gimpel lint folks. I'm sure they'd be extremely interested in them.

  8. #38
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Elysia's next point is almost certainly that in the context of the original program, pDay should be of const char *, at least, due to the fact that assigning to a string literal invokes undefined behavior.

    For example
    pDay[0][2] = 'N';

    as unlikely as that is to occur

    She normally doesn't focus on whether pointers would be reassigned (which is safe in this context), but she never fails to scribble off a post about it. She likes to discuss the same talking points repeatedly, even if she can be inept at doing so. The use of the const keyword is largely a matter of adherence to specification.
    Last edited by whiteflags; 11-03-2008 at 12:25 PM.

  9. #39
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I have a function that I wrote that does something like this (it was part of a planner program I wrote for Windows CE a while back). Long story short, its been more than 6 hours since your initial post and I am more likely to be friendly to you if you are at least nice enough to bribe me with mexican food or at least send a birthday card...

  10. #40
    Registered User
    Join Date
    Oct 2008
    Posts
    18
    thanks people but i took help from another forums so thanks for giving your ideas

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Challange for Cprogramming.com
    By umar7001 in forum C++ Programming
    Replies: 28
    Last Post: 04-15-2007, 08:31 AM
  2. Digit selector... (Mathmatically complex, for some)
    By Axpen in forum C Programming
    Replies: 17
    Last Post: 08-28-2004, 02:58 PM
  3. Stuck on a friend's challange
    By wiresite in forum C++ Programming
    Replies: 32
    Last Post: 04-23-2004, 07:36 AM
  4. Timecard Challange
    By Thantos in forum Contests Board
    Replies: 2
    Last Post: 11-20-2003, 04:12 PM
  5. Chess Challange
    By kosmoludek in forum C Programming
    Replies: 4
    Last Post: 01-12-2003, 04:53 PM