![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
Any Sample???
Write a program that read a line of text, changes each uppercase letter to lowercase and places each letter both in a queue and onto a stack.
The program should then verify whether the line of text is a palindrome Output: Please enter a line of text I am A.I i AM a.i This is a palindrome |
|
|
|
| Sponsored Links |
|
|
#2 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 34,235
OS: XP-Pro, Vista, Linux
Blog Entries: 1
|
I think the object of the homework is you're supposed to learn to program, not to copy/paste the code from us.
![]() We'll be glad to help if you run into a problem, but what's the point of providing the program, what will you learn in that case?
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|
|
#4 (permalink) |
|
Assistant Manager, Microsoft Support
Join Date: Jul 2002
Location: Knoxville, TN or Austin, TX depending
Posts: 6,301
OS: WinXP Pro SP2 and Slackware 10.1
|
I'd check it with the ascii code...
lower case letters number from 97 to 123 upper case letters number from 65 to 90 Code:
if (*var > 96 && *var < 124);
printf("is lower case");
else if (*var > 64 && *var < 91);
printf("is upper case");
...oh and *var should be replaced with whatever variable you stored the line of text as.
__________________
![]() ![]() If TSF has helped you, Tell us about it! or Donate to help keep the site up! I do not subscribe to threads, so if I stop replying, PM me with a link to your thread so I can find it again. |
|
|
|
|
|
#5 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 34,235
OS: XP-Pro, Vista, Linux
Blog Entries: 1
|
You can use strlwr() or strupr() to convert strings to lower or upper case, then it's easy to compare them. You can also do case insensitive string comparisons strcmpi().
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|
|
#6 (permalink) |
|
Assistant Manager, Microsoft Support
Join Date: Jul 2002
Location: Knoxville, TN or Austin, TX depending
Posts: 6,301
OS: WinXP Pro SP2 and Slackware 10.1
|
Yea I always forget about those functions...when I was in my C class we had to write a program for a test (in class) that converted the string to upper case...I did it the hard way with the ascii code. Surprisingly I was one of the few people who passed the test (and one of 3 who passed the class).
__________________
![]() ![]() If TSF has helped you, Tell us about it! or Donate to help keep the site up! I do not subscribe to threads, so if I stop replying, PM me with a link to your thread so I can find it again. |
|
|
|
|
|
#7 (permalink) |
|
TSF Enthusiast
Join Date: Dec 2004
Posts: 604
OS: windows xp
|
This is an example of what you must do WITH OUT USING STACKS AND QUEUE. I do not have the time to make a Queue and Stack class and I dont seem to have one on my computer right now.
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
too PHP Code:
I did not test the changes needed to make it work with stack and queue. My orginal program is tested and works perfect. You might have to do a little tweaking I missed to make it work with a stack and queue class. Like always my program is given as a method to learn the skills not so you dont have to do it. I provide a program ONLY because if you like me you learn best by looking at examples of code.
__________________
Last edited by mgoldb2 : 10-11-2005 at 12:00 AM. |
|
|
|
|
|
#8 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
I really do have problem implementing the stack and queue class. Is it something like this???
template<class Type> class queueType: { public: int getsize(); char DEQUEUE(); char ENQUEUE(); }; template<class Type> class stackType { public: int getsize(); char push(); char (pop); }; Is it that i need to implement it like this? and Which part of the program should i implement it? Do i need to create another header file for stack and queue? And i have some questions too...juz hoping to learn more. 1.what is #include<istream> means? 2. cin.getline(x,256,'\n'); What does the x and 256 means? 3. if (x[c] > 96 && x[c] < 124 What does 96 and 124 refers to here? Thank u very much for your help buddy...i agree that looking on codes do help me more effectively...a million thanks to u. And btw,can u make the program to be able to verify whether the input is in uppercase and if it is...the program will change it to lower case? I totally have no idea in this...hope to see from u again soon...thanks. |
|
|
|
|
|
#9 (permalink) | ||||
|
TSF Enthusiast
Join Date: Dec 2004
Posts: 604
OS: windows xp
|
Quote:
Quote:
to sumerize these are the conditions for cin.getline cin.getline(char array, number of char to take in, when to exist user input) Quote:
PHP Code:
Quote:
I would use a header file for each classe Then most of the time you use anouther .cpp file to implment the classes. PHP Code:
__________________
|
||||
|
|
|
|
|
#11 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
Well if we can use strlwr(x); to convert all input to lowercase...is there any way we can make the program to change the uppercase to lower case and the lower case to upper case? How can we implement 2 functions at the same time?
For example: I am AI Then after execution it will become: i AM ai It will change the lower case letters to uppercase and at the same time changes the uppercase letters to lower case...this is really confusing me.... |
|
|
|
|
|
#13 (permalink) | |
|
TSF Enthusiast
Join Date: Dec 2004
Posts: 604
OS: windows xp
|
Quote:
.cpp containg main program include both .h files in it .cpp containg stack implementation include stack .h file in it .cpp contain QUEUE implementation include qeue.h file in it .h containing stack declaration .h containg queue declaration
__________________
|
|
|
|
|
|
|
#14 (permalink) | |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 34,235
OS: XP-Pro, Vista, Linux
Blog Entries: 1
|
Quote:
![]()
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|