help with code..

C, C++, Visual C++, C++.Net Topics
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: help with code..

Post by Saman » Tue Aug 23, 2011 12:08 pm

so you don't need to use scanf right?
He has already decided he is not going to use it. He can input a set of arguments at once with scanf. No idea why ;)
what you need is to write your own lexer to parse it.
He wasn't aware of what he really needs. He just found a code written for something else and wanted to modify that for his requirement.
There is something called Finite State Machines for that.
Though the inline process is a DFSA, for such small algos, it is not good to get complicated with them. FSAs are usually used when complicated logic is involved and handling them precisely is needed. So for Ghost (I remember he is a student if memory is correct) I also think he should write a pseudo code for his algorithm first. Without knowing what he needs, modifying someone's code is not going to work.
User avatar
SemiconductorCat
Major
Major
Posts: 455
Joined: Mon Aug 22, 2011 8:42 pm
Location: currently in hyperspace

Re: help with code..

Post by SemiconductorCat » Wed Aug 24, 2011 1:38 am

Without knowing what he needs, modifying someone's code is not going to work.
Go through a dry run , so that's the 1st step of deep code reviewing.With pencil and paper until it kicked to the head.
Post Reply

Return to “C/C++ Programming”