SeeTheLite 20 Junior Poster

For the purposes of two dimensional arrays, the "rows" and "columns" are declared, in a sense, by the user; depending on which one he or she calls first. For instance, you can do

for(i = 0; i <  9; i++)
   for(j = 0; j < 9; j++) {
       grid[i][j]=x;
       x++;
}

//or

for(j = 0; j <  9; j++)
   for(i = 0; i < 9; i++) {
       grid[i][j]=0;
       x++;
}

both loops will give the same output if called in the same way as they are declared(i first or j first). That being said, he needs to check for both rows and columns for his program

SeeTheLite 20 Junior Poster

While friend classes are similar, they also allow the manipulation of private variables from an inherited class, which is why virtual functions are used, for access.

SeeTheLite 20 Junior Poster

I'm trying to leave some of the code for you to do, but to clarify; you need to check both rows and columns. In this case, you are only checking i. What you need to do is create a second for loop to check j. However here is the problem I am talking about(and was probally vague on) Say j = 5 and you go through your first loop, which checks rows, and find a repetition, j is now 4. After this loop you have a second loop to check columns, and if this also fails, j is now = to 3. So what you need to do is make a flag that prevents the program from entering the second loop if the first check failed.

SeeTheLite 20 Junior Poster

What compiler are you using? Tag a system("pause"); before return 0; and see what happens. Also

int multiplyDigits(int productOfDigit1, int productOfDigit2, int productOfDigit3, int productOfDigit4, int productOfDigit5)
{
	int digit1 = 0, digit2 = 0, digit3 = 0, digit4 = 0, digit5 = 0, valueDigit1 = 0, valueDigit2 = 0, valueDigit3 = 0, valueDigit4 = 0, valueDigit5 = 0;
	productOfDigit1 = digit1 * valueDigit1;
	productOfDigit2 = digit2 * valueDigit2;
	productOfDigit3 = digit3 * valueDigit3;
	productOfDigit4 = digit4 * valueDigit4;
	productOfDigit5 = digit5 * valueDigit5;
	return 0;
}

seems a bit confusing, why do you declare everything as 0 if you already declared valueDigit and taken the input of digit? The way I read this is

int multiplyDigits(int productOfDigit1, int productOfDigit2, int productOfDigit3, int productOfDigit4, int productOfDigit5)
{
	int digit1 = 0, digit2 = 0, digit3 = 0, digit4 = 0, digit5 = 0, valueDigit1 = 0, valueDigit2 = 0, valueDigit3 = 0, valueDigit4 = 0, valueDigit5 = 0;
	0 = 0* 0;
	0= 0* 0;
	0= 0* 0;
	0= 0* 0;
	0= 0* 0;
	return 0;
}
SeeTheLite 20 Junior Poster

Have you tried it? Compile it and see how it goes. Alternatively, you can put the code under one case into a function and call it on both cases.

SeeTheLite 20 Junior Poster

I remeber doing a similar program a few months ago as a joke with my friend. Our teacher asked us to create a soduku solver so we created an algorithm to test every possible combination of ansewers in a number until it was correct. What you are trying to do(or atleast what I think you are) is create a row of unique numbers while checking the column is unique. However, we used a structure with checksums and arrays for each row/column which might be a little more than you want to get into. But anyways, for your purposes, you are not checking the entire row/column; only the previous element, which makes your problem very simple. Just make two for loops to check the current column and row of the element. In addition, you will want to set the whole array to 0 if you use this method:

for(x = 0; x < 9; x++) {
if(i != x) {
if(grid[i][j] == grid[x][j])
j--;
x = 9;
}
}

just repeat this loop twice for 'j' and it will check the corresponding rows and columns. However, you will also need to make a flag to ignore the second loop if the first one fails so j is not subtracted twice. I hope this helps!

SeeTheLite 20 Junior Poster

Virtual functions used to call on private variables from another class(in my understanding)

so if you have:

class one {

public:
one();
virtual void getone() {return data;}

private:
int data;

};

class two : public one {

public:
two();
virtual void getone() {return data;}
};

you would be able to access class one's variable data from class two.

SeeTheLite 20 Junior Poster

Forgive me if I'm wrong but it appears you have not declared TotalSold yet. If you haven't encountered a similar problem already, it typically results because int TotalSold is set to a random integer(483432) for instance before you set it. So just write TotalSold = 0; in your constructor and you should be good to go :D

-Cheers

SeeTheLite 20 Junior Poster

Hey guys, I'm Kevin, hows it going?

random stuff about me:
Age/sex: 16/M

Hobbies: reading,swimming,writing poetry,piano,games, music

Musical genres: progressive rock, hardcore/thrash, techno, trance, indie, alternative, industrial, symphonic rock, classical, thug

occupation:student/lifegaurd

Goals(programmingwise): I'm currently learning c++ at my school but hope to expand my repetoire to include c#, java, and lua; as well as some python if possible.

Why I like Programming: It's fun because it extends(or rather solidifies) problem solving. Its like a puzzle with an infinite number of solutions, and the best(and worst) part is your code will only do what you tell it to do(reliability).

Other Things: I can be a grammar nazi at times and I tend to lose my self in arguments for fun.(exciting, I know)