Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 86,372 C++ Programmers. There are 1,445 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a C++ Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

if statement

 
Reply to this topicStart new topic

if statement

kckc314
post 8 May, 2008 - 10:34 PM
Post #1


D.I.C Head

**
Joined: 5 Apr, 2008
Posts: 75



what's the errors in this code?
CODE

if (c < dCol && ((sq[r][c + 1] != '#' && sq[r][c + 1] != ' ') || (sq[r - 1][c] != '#' && sq[r - 1][c] != ' ') ||
        (sq[r][c - 1] != '#' && sq[r][c - 1] != ' ') || (sq[r + 1][c] != '#' && sq[r + 1][c] != ' ')) &&
        sq[r][c + 1] <= sq[r - 1][c] && sq[r][c + 1] <= sq[r][c - 1] && sq[r][c + 1] <= sq[r + 1][c])
        spmw1(r, c + 1);
     else
     if (r > dRow && ((sq[r - 1][c] != '#' && sq[r - 1][c] != ' ') || (sq[r][c - 1] != '#' && sq[r][c - 1] != ' ') ||
        (sq[r + 1][c] != '#' && sq[r + 1][c] != ' ') || (sq[r][c + 1] != '#' && sq[r][c + 1] != ' ')) &&
        sq[r - 1][c] <= sq[r][c - 1] && sq[r - 1][c] <= sq[r + 1][c] && sq[r - 1][c] <= sq[r][c + 1])
        spmw1(r - 1, c);
     else
     if
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


zattara13
post 8 May, 2008 - 10:50 PM
Post #2


New D.I.C Head

*
Joined: 27 Mar, 2008
Posts: 23

between one statment and the other in the if, try using brackets example:

if ( (x=2) || (y=3) || (f=2) ) ....

that could be one problem

the other can be that i am not sure if the program accepts (!= '#') as a stamtent. not sure about that tough. the other thing is u better check the || and && because u need to understand the logic, not the english.

hope it helps

ZaTTaRa


QUOTE(kckc314 @ 8 May, 2008 - 10:34 PM) *

what's the errors in this code?
CODE

if (c < dCol && ((sq[r][c + 1] != '#' && sq[r][c + 1] != ' ') || (sq[r - 1][c] != '#' && sq[r - 1][c] != ' ') ||
        (sq[r][c - 1] != '#' && sq[r][c - 1] != ' ') || (sq[r + 1][c] != '#' && sq[r + 1][c] != ' ')) &&
        sq[r][c + 1] <= sq[r - 1][c] && sq[r][c + 1] <= sq[r][c - 1] && sq[r][c + 1] <= sq[r + 1][c])
        spmw1(r, c + 1);
     else
     if (r > dRow && ((sq[r - 1][c] != '#' && sq[r - 1][c] != ' ') || (sq[r][c - 1] != '#' && sq[r][c - 1] != ' ') ||
        (sq[r + 1][c] != '#' && sq[r + 1][c] != ' ') || (sq[r][c + 1] != '#' && sq[r][c + 1] != ' ')) &&
        sq[r - 1][c] <= sq[r][c - 1] && sq[r - 1][c] <= sq[r + 1][c] && sq[r - 1][c] <= sq[r][c + 1])
        spmw1(r - 1, c);
     else
     if


User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
Time is now: 5/17/08 02:40AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month