|
aLiSoN3742 wrote:
I'm not sure how to write just a code segment. Not being able to run it leave s me without any direction to go in (knowing if it's right or wrong).
well, just put your code segment in a function , than write a program that passes in a palindrome to function containin the code your testing , and provide a return TRUE or FALSE from that function if its a palindrome or not..
You could test your code segment this way and if you need to just hand in the segment, you take it outta the function once your sure the code works.
or dont even put your code in a function, and hardcode a CString Palindrome = "ABLE WAS I ERE I SAW ELBA"; to act upon in your testing.
aLiSoN3742 wrote:
I would really like to find a teacher's version of this book, or an answer guide someplace! Thank you! Alison
------------------------------------
Using one or more stacks, write a code segment to read in a string of characters and determine whether it forms a palindrome. A palindrome is a sequence of characters that reads the same both forward and backward--for example: ABLE WAS I ERE I SAW ELBA.
The character '.' ends the string. Write a message indicating whether the string is a palindrome. You may assume that the data are correct and that the maximum number of characters is 80.
-------------------------------
i'd help you w/ some code, but as a general rule of thumb, cp'ers dont do other peoples homework. is there anything in particular that is giving you trouble that someone could assist you with? do you have any code written ? the answer 'all of it' doesnt go over well here....
todo....
:: insert inspirational text here ::
|
|
|
|
|
I would say push the first half of the string onto your stack then compare the stack contents to the rest of the string (since the stack contents will be in reverse order - that's just how a stack works).
If they say write a code segment I think it just means write the algorithm and if you need extra code to test the algorithm then don't include that extra test code in your submission.
|
|
|
|
|
Is this an assembly language class?
|
|
|
|
|
Do it on paper first. Get to know the problem. It's not that hard! You will not accomplish anything by asking others to do your homework for you.
I know nothing about you and your current situation. But if you have problems sorting this small problem out, then I suspect you should study something else... or try harder! Hard work has its rewards.
--
They're out get me, I can't escape cos' they won't let me
They won't forget me, they'll get me in their grip and sweat me
They'll wait me out, and then move in under my skin
They'll make me doubt, they're out to make me let them in
|
|
|
|
|
Hi... I'm beginner in C++ and MFC. I'm building an application that interface with a robotic arm... I have already done that part. I'm missing a part where I have a trajectory in (X,Y,Z) and the arm follows the trajectory. I can handle the mathematical stuff to generate the trajectory but I guess I would be nice to have the target trajectory and the real one plotted in the screen. I have somebooks about visual C++ and MFC, but it is hard for me to diggest them.
What I have learnt from the reading is:
1) How to show a window,
What I know I need is:
1) Put the (0,0) in the middle of the window,
2) Draw the X,Y,Z axis (taking care of the scaling)
3) Pass the trajectories generated to be ploted.
However all this, I'm still confused with the MFC and the modes, and the coordinates.
Is there any tutorial that lead me step by step to create an application like that...
I like to follow that by creating a demo application to plot an ellipse. Then, I can pass it over my main application, to plot trajectories (the target and the real) together with the error of a trajectory. Both in a window, trajectories in the top and the error in the bottom. Then, of course I would like to save them and/or printing.
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
|
I am trying to create a time comparison algorithm, and i have had some issues with it. I was wondering if anyone out there has had a problem with this, or if anyone solved this problem. Any help would be appreciated.
-- Steve
|
|
|
|
|
What's a "time-comparison" algo?
bEqual = CompareTime("23:00", "11:00 PM");
Or are you looking for a ready made time-comparison component?
(I do not have the answer, just being noisy)
|
|
|
|
|
I'm trying to create a function similar to your CompareTime(). Basicly, the main issue is telling the difference between say 1:35:59 and say 1:36:05. I need a way for the computer to figure out that there is a 6 second difference between those 2. Once I can figure that out, the rest will be easy.
-- Steve
|
|
|
|
|
you said it yourself, take the "difference" i.e. subtract one time from the other. If they're not in a form that allows arithmetic then convert them to such a form (there must be support for that).
Maybe I'm not understanding your question... it's pretty vague.
|
|
|
|
|
Use mktime() to obtain a time_t value from individual time fields, then use difftime() . Or you can roll your own algorithm like so:
long differenceInSeconds
(long nStartHour,
long nStartMinute,
long nStartSecond,
long nEnd Hour,
long nEndMinute,
long nEndSecond)
{
long nStart = nStartHour*3600 + nStartMinute*60 + nStartSecond;
long nEnd = nEndHour*3600 + nEndMinute*60 + nEndSecond;
return (nEnd - nStart);
} I hope you didn't make me do your homework. (You're only cheating yourself, if you did).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi !
I am ran into a great problem I can not solve. I need to write a Dial-Up Server project in Win98 by visual c++.
I do followed steps:
1) With TAPI wrote a program that can wait fo call.
2) After client Dial-in (by Dial-up networking),my program answer and connect to client. But problem is here that I can't write the code that build the RADIUS packet for reply to packet that is sent from client.
If could help, please let me know.
A BIG thanks in advance.
|
|
|
|
|
Hi Guys this is very urgent!.
I am tryieng to use extern in my application. I am declaring
extern CAzg a;
and also I have specified header file in include
but I ma getting linkage error.
Can any one solve this and can tell me how to over come this problem.
God Knows Better
|
|
|
|
|
Your project also needs a .cpp file that contains the definition of a , i.e:
CAzg a;
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yes I have both .h and .cpp file in the project folder.
God Knows Better
|
|
|
|
|
Couldn't you have asked God for help?
--
They're out get me, I can't escape cos' they won't let me
They won't forget me, they'll get me in their grip and sweat me
They'll wait me out, and then move in under my skin
They'll make me doubt, they're out to make me let them in
|
|
|
|
|
Thanks for your Great suggestion. My God bless you!!
God Knows Better
|
|
|
|
|
Hi! I am writing a custom control, and I would want to draw two overlapping images using transparency. I have written this code, but it does not work! Does anybody know the correct way of drawing overlapping bitmaps with transparency ? Thank you !
void CMyClass::DCDrawBitmap(HBITMAP hBitmap,LPRECT lpRect)
{
CDC* pDC = this->GetDC();
CDC dcSrc;
dcSrc.CreateCompatibleDC(pDC);
dcSrc.DrawState(CPoint(0,0),CSize(m_iCellWidth, m_iCellHeight),
hBitmap,DST_BITMAP|DSS_NORMAL);
pDC->TransparentBlt(lpRect->left,lpRect->top,m_iCellWidth,m_iCellHeight, &dcSrc,0,0,m_iCellWidth,m_iCellHeight,RGB(255,255,255));
ReleaseDC(&dcSrc);
ReleaseDC(pDC);
}
www.eugigames.tk
|
|
|
|
|
I want to return data in m_pStack[0] from a method. m_pStack is declared like this:
char** m_pStack = new char*[bla bla];
My method looks like:
void CStack::Pop(char* elem)
{
elem = m_pStack[0];
...
}
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Aargh.. I'm too fast to post messages... memcpy is my solution.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Hi There,
I am workin on a MDI Document. in that i have a view which will display a Bitmap Image. Every time i open my Bitmap image a new instance of Document class is being created. But what my requirement is that every time i open a Bitmap it should be opend in the Document instance that has been created at the starting of the application.
How can i do it. plz help me out its urgent.
Sreeramachandra G
|
|
|
|
|
I just want to know that how can we submitt our research papers to Microsoft so that it will publish it in its Journal.
God Knows Better
|
|
|
|
|
If you have a string:
char * pName="Paul";
You need to write a small code to reverse the string. The code must be as efficient as possible:
char * pReversedName;
int nLength=0;
nLength=strlen(pName);
pReversedName= new char[nLength];
//Just a simple byte-to-byte copy:
for(int i=0; i
|
|
|
|
|
c-strings are null terminated, always add one to the length of the string if you need to copy the whole string.
pReversedName = new char[nLength+1];
or better yet, use the STL string class (std::string)
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks. But besides that, do you think there's an even more efficient way of spelling a string backward? Using ANSI C++?
|
|
|
|