Visit the Ironworks Gaming Website Email the Webmaster Graphics Library Rules and Regulations Help Support Ironworks Forum with a Donation to Keep us Online - We rely totally on Donations from members Donation goal Meter

Ironworks Gaming Radio

Ironworks Gaming Forum

Go Back   Ironworks Gaming Forum > Ironworks Gaming Forums > General Discussion > General Conversation Archives (11/2000 - 01/2005)
FAQ Calendar Arcade Today's Posts Search

 
 
Thread Tools Search this Thread
Old 11-21-2002, 02:22 PM   #1
Blade
Emerald Dragon
 

Join Date: March 12, 2001
Location: spokane wa usa
Age: 40
Posts: 926
I'm working on a c++ assignment and i need a little help. I have to compare two end slots in a char array and work my way in ex. first with last, second with second to last ect., then return wheather all the charecter match or not. I can't figure out how to exactly to do it. I know it has something to do with a loop and an if statement but how how exactly i can't figure out.
__________________
<br /><br />All blades cut, be they made from metal or wood, but the sharpest and deadliest blade is the one of knowledge, and that is the least used.<br />An Archmage of the HADB
Blade is offline  
Old 11-21-2002, 03:59 PM   #2
NiceWorg
Baaz Draconian
 

Join Date: January 15, 2002
Location: Vaasa, Finland
Age: 42
Posts: 772
Sorry, I have no clue, and I spam this just to promote Java. It makes everything so much easier.
__________________
Fell in love with a country girl, morning sunshine<br />She was up from a nether world, just to bust another soul<br />[url]\"http://jarkokson.suddenlaunch.com\" target=\"_blank\">Click!</a>
NiceWorg is offline  
Old 11-21-2002, 04:01 PM   #3
Blade
Emerald Dragon
 

Join Date: March 12, 2001
Location: spokane wa usa
Age: 40
Posts: 926
don't know java, plus this is a c++ class so [img]tongue.gif[/img] its fun and not to hard just time consuming. Less now though that i'm using Visual Basic great program and you can use lots of languages in it.
__________________
<br /><br />All blades cut, be they made from metal or wood, but the sharpest and deadliest blade is the one of knowledge, and that is the least used.<br />An Archmage of the HADB
Blade is offline  
Old 11-21-2002, 04:06 PM   #4
andrewas
Harper
 

Join Date: October 2, 2001
Location: Aberdeen, Scotland
Age: 42
Posts: 4,774
code:
for(n:=0,m:=len(str)-1;n>m;n++,m--)
{
// your camparison goes in here
}
[/QUOTE]Ye gods but I havent used this stuff in while. That for loop is fairly simple -initialise n and m to the beginning and end of your string, end the loop when n is more than m, each loop increment n and decrement m.

But I think youll need to check the logic, run through it (on paper) with odd and even length strings. And get a textbook and make sure that thats the correct syntax for a two-variable for loop, I havent used one in *years*. Easiest way to return the result is

code:
result:=true;
for(n:=0,m:=len(str)-1;n>m;n++,m--)
{
if(str[n]!=str[m] then
result:=false;
}
return(result);
[/QUOTE]Heh - as you can see Im confusing Pascal and C++ syntax. Trouble with switching languages so often [img]smile.gif[/img] Anyway, that bit is fairly standard logic. Only one fail is needed to fail the whole lot, so you may want to optimise with a break statement, but I woudnt bother outside of a performance critical function, which this isnt as its a homework problem.
__________________
[img]\"http://www.sighost.us/members/Zvijer/andrewas.gif\" alt=\" - \" />
andrewas is offline  
Old 11-21-2002, 04:13 PM   #5
WillowIX
Apophis
 

Join Date: July 10, 2001
Location: By a big blue lake, Canada
Age: 50
Posts: 4,628
Andrewas, you really ought to add something like "Official computer expert of IW" or something in your signature! [img]graemlins/thumbsup.gif[/img] BTW andrewas, do you know if I can manually add the acrobat script to Word XP? The one that allows you to convert to PDF without changing printer properties? (I think it´s called acrobat.dot) [img]smile.gif[/img]
__________________
Confuzzled by nature.
WillowIX is offline  
Old 11-21-2002, 08:16 PM   #6
SirTristram
Manshoon
 

Join Date: November 2, 2002
Location: Calgary, Alberta
Age: 37
Posts: 155
Is this an assignment to find out if a word is a palindrome? if it is, do NOT compare 1st to last, 2nd to 2nd last, etc. instead, reverse your original string and then compare the two...
__________________
SirTristram is offline  
Old 11-22-2002, 01:42 AM   #7
Blade
Emerald Dragon
 

Join Date: March 12, 2001
Location: spokane wa usa
Age: 40
Posts: 926
well i allready did that for on funcition, we need to do it two different ways. Sorry for the late reply i have been of doing things. I'll give it a try andrewas
__________________
<br /><br />All blades cut, be they made from metal or wood, but the sharpest and deadliest blade is the one of knowledge, and that is the least used.<br />An Archmage of the HADB
Blade is offline  
Old 11-22-2002, 02:02 AM   #8
Blade
Emerald Dragon
 

Join Date: March 12, 2001
Location: spokane wa usa
Age: 40
Posts: 926
well here i would post my code here so people could confuse themselves but it says html code error, doesn't allow parenthasis on my o well thank for the help, it works. I knew it would just coudn't figure out how to put it into code thanks.
__________________
<br /><br />All blades cut, be they made from metal or wood, but the sharpest and deadliest blade is the one of knowledge, and that is the least used.<br />An Archmage of the HADB
Blade is offline  
Old 11-22-2002, 02:10 AM   #9
/)eathKiller
Dracolisk
 

Join Date: January 5, 2002
Location: Guantanamo Bay, Cuba
Age: 38
Posts: 6,043
well you do know that Java and C++ are cousins...
__________________
[img]\"http://membres.lycos.fr/th8or/ZeroSigForIronworks.gif\" alt=\" - \" /> o.o;
/)eathKiller is offline  
Old 11-22-2002, 02:16 AM   #10
Blade
Emerald Dragon
 

Join Date: March 12, 2001
Location: spokane wa usa
Age: 40
Posts: 926
there are lots of simular languages there Death, c++, java, and basicaly any general overall languages are related. They all take the code and encode it into the same basic language, that is how all the .net stuff works you know.
__________________
<br /><br />All blades cut, be they made from metal or wood, but the sharpest and deadliest blade is the one of knowledge, and that is the least used.<br />An Archmage of the HADB
Blade is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Another Video Card Question becomes Antivirus Question!!! Bahamut General Conversation Archives (11/2000 - 01/2005) 19 12-27-2003 11:40 PM
One BIZZZARE question and one normal everyday question Sythe Baldurs Gate II: Shadows of Amn & Throne of Bhaal 3 09-10-2002 02:44 AM
Early ch6 question - poss spoiler info in question... Fljotsdale Baldurs Gate II Archives 5 03-18-2001 12:33 AM
Dragon spire crystal question + question about Giant killing for the warriorguild Malakez Wizards & Warriors Forum 4 02-20-2001 03:52 PM
spell lvl question, buying spells question, and role ascension question Paupa Wizards & Warriors Forum 1 12-31-2000 04:59 PM


All times are GMT -4. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved