[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/04/2008 at 05:02PM PDT, ID: 23704740
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.7

I suck at C++ syntax...

Asked by molerner in C++ Programming Language, Programming Languages, Windows Programming

Tags: like, no fooling, I can't code for my life, especially when it comes to arrays

...and I need some help in making my program, you know, compile.

I mean, the fact that the code is really inefficient is beside the point. I just want this thing to come out on the other side of my compiler.

I took out a huge chunk of really simple commands that I know are done correctly. I commented it where I took it out from. I'm trying to make it easy on you experts.

I think my main problem is that I have no understanding on how functions are called and also that I'm really poor at managing arrays. I think I've tried to declare an array in about 50 different incorrect ways at once. However, I'm fairly sure that I've semi-coloned and bracketed OK... fairly sure...

Really, people, save me from myself.

What rules do I seem unaware of?

P.S. You may find that I've taken an extra step (such as initializing a variable that's used only once). This is most likely because I was trying to make things as simple as possible when I tried to debug things myself. Just an explanation in case you get confused.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
#include <cstdlib>
#include <iostream>
 
using namespace std;
 
void mapout(int);
bool comptwo(int[2], int[2]);
bool checkall();
int placeq(int,int,int);
void printmap();
 
 
int pathnum=1; //how many queens are on the board right now?
int queens[8][2]={}; //the set of queens. I used a 8x2 table (even though the first column will always be the same, 1-8) so that the program is expandable.
int xplace;
int yplace;
int nq;
 
 
int main(void)
{
    int hits=0;
    while(hits<1){    //this is if we want to find one result.
 
for (int row=1;row<9;row++){
    int stopit=0;
for (int col=1;col<9 & stopit<1;col++){
    placeq(row,col,pathnum);
    pathnum++;
    if (checkall()==true){
                          stopit=1;
                          pathnum++;
                          }
                          pathnum--;
                          }
    if (stopit==0){
                   pathnum--;
                   row--;
                   }
                   }
                   }                              
    
printmap();
                   
}
 
bool checkall(){
     int compareworks;
     for (int j=1;j<pathnum+1;j++){
         
     for (int i=1;i<pathnum+1;i++){
         compareworks=comptwo(queens[i],queens[j]);
         if (compareworks==0 & j!==i){
                                                                                     return false;
                                                                                     }
                                                                                     }
         }
}
     
bool comptwo(c1[], c2[]){
     if (c1[1]==c2[1]||c1[2]==c2[2]){ //horizontal and vertical check
                                     return false;
                                     }
     if (c1[1]+c1[2]==c2[1]+c2[2]){ //diagonal down-left to up-right
                                         return false;
                                         }
     if (c1[2]-c1[1]==c2[2]-c2[1]){ //diagonal down-right to up-left
                                    return false;
                                    }
     return true;
     }
                                   
 
void mapout(place){
//some really basic but long code went here...
                  }
 
void printmap(){
     for (int i=1; i<9; i++){
         for (int j=1; j<9; j++){
             if queens[j][1]==i{
                                mapout(queens[j][2]);
                                }
                                }
                                }
                                }
int placeq(xplace,yplace,nq){
     queens[nq][1]=xplace;
     queens[nq][2]=yplace;
     pathnum=nq;
     return 1;
     }
[+][-]09/04/08 05:24 PM, ID: 22394168

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C++ Programming Language, Programming Languages, Windows Programming
Tags: like, no fooling, I can't code for my life, especially when it comes to arrays
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09/04/08 05:29 PM, ID: 22394199

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/04/08 08:06 PM, ID: 22394912

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/04/08 10:56 PM, ID: 22395603

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/05/08 04:49 AM, ID: 22397590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/05/08 10:07 AM, ID: 22401222

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/05/08 11:16 AM, ID: 22401972

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/05/08 12:27 PM, ID: 22402804

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_EXPERT_20070906