help meeeeeee...ARRAY PROBLEM...

Hello everybody here on the forum..am having a problem and i want somebody to help me out...am writing this program which is doing my head in...this is a part of the code...

#include <iostream>

int ROW;

using namespace std;
int main ()
{
ROW=44;
int LN [][5]={
/* 0*/ {37,13, 20, 84, 90},
/* 1*/ {26,83, 90, 72, 79},
/* 2 */{41,80, 39, 60, 40},
/* 3*/ {4, 46, 85, 61, 9 },
/* 4*/ {44,62, 74, 70, 49},
/* 5*/ {28,33, 72, 62, 88},
/* 6*/ {20,5, 6, 25, 71},
/* 7 */ {3, 9, 15, 84 ,34},
/*8*/{7, 52, 25, 83, 88},
/* 9*/{15,35, 67, 78, 6},
/*10*/ {53,38, 2, 10, 49},
/*11*/ {43,83, 17, 37, 15},
/*12*/ {90,36, 59, 3, 64},
/*13*/ {59,19, 28, 58, 76},
/*14*/ {51,81, 2, 8, 67},
/* 15/*/{64,72, 45, 86, 5},
/* 16*/{77,89, 38, 72, 45},
/*17*/{34,1, 74, 61, 89},
/*18*/{31,25, 75, 37, 84},
/*19*/ {23, 59, 57, 50, 77},
/*20*/ {79,90, 1, 23, 16},
/*21*/ {25,34, 22, 84, 7},
/*22*/ {70,46, 30, 37, 90},
/*23*/ {72,55, 75, 64, 71},
/*24*/ {90,8, 84, 36, 30},
/*25*/ {34,79, 81, 20, 12},
/*26*/ {82,56, 77, 49, 69},
/* 27*/ {42,30, 89, 84, 59},
/*28*/ {10,6, 68, 50, 87},
/*29*/ {28,7, 55, 62, 58},
/*30*/ {31,25, 86, 84, 87},
/*31*/ {36,66, 53, 3, 77},
/*32*/ {25,13, 72, 70, 47},
/*33*/{34, 77,80, 53, 33},
/*34*/ {86, 71, 23, 90, 8},
/*35*/{81, 45, 69, 38, 72},
/*36*/ {24, 61, 74, 41, 72},
/*37*/ {30, 27, 66, 43, 13},
/*38*/ {69, 20, 15, 64,59},
/*39*/ {14, 28, 59, 42, 67},
/*40*/ {2, 31, 88, 28, 55},
/*41*/{60, 73, 63, 19, 82},
/*42*/{67, 4, 42, 27, 29},
/*43*/ {16, 2, 51, 19, 74}
};
int r, c, k, Possiblenumbers1, Numberofpossiblenum=0;



for (r=0; r<ROW; r++)for (c=0;c<5;c++)

{
if (LN[r][c]==LN [ROW-1][0]||LN [ROW-1][1]||LN [ROW-1][2]||LN [ROW-1][3]||LN [ROW-1][4])/*if at least a figure of row analysed equal to a figure of jumping board row*/
{r=+1,Numberofpossiblenum=+5;

for (c=0;c<5;c++)

{
cout<<"row number;"<<r<<endl<<"A possible number;"<<LN[r][c]<<endl<<"number of possible numbers are:\n"<<Numberofpossiblenum<<endl;}}
else
cout<<"for rolling one no values..."<<endl;



}


return 0;}

well the problem is that...i simply want the program to read the array going row by row column after column..comparing every single number to row 43...and if and only if a number of a particular row should be equal to that of any number of row 43...then the next row of that number should be printed on the screen..i think is should be a simple thing but my program is giving me wrong things..it works alright but the output is not what i want...i mean is wrong..so i think am making a mistake somewhere...SOMEBODY HELP ME OOOOUUUUUOUTTTT...thanks in advance :)




in if statement you are comparing only column 0 of LN. Remaining column comparing for true.

try this:
1
2
3
4
5
6
if (LN[r][c]==LN [ROW-1][0]
  ||LN[r][c]==LN [ROW-1][1]
  ||LN[r][c]==LN [ROW-1][2]
  ||LN[r][c]==LN [ROW-1][3]
  ||LN[r][c]==LN [ROW-1][4])/*if at least a figure of row analysed equal to a figure of jumping board row*/
  {
sorry FredFlinstone..what is the different between what you have written from what i have??? i think you just have it in a vertical order and i have it in a horizontal order but is the same...
may be am not understanding something..anyway..let me try it out your style...i will comeback to give results...thanks man :)
Last edited on
i tried it and the result is the same..now the whole thing is looping like mad....i mean although is looping and the resultings are moving very fast i still managed to read and i can see that..the result is wrong...may be i have to insert a break somewhere but i dont even know where...HELP MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
In your following code you are missing to compare LN[ROW-1] column1, 2, 3, 4 with LN[r][c].
1
2
3
4
5
if (LN[r][c]==LN [ROW-1][0]
||LN [ROW-1][1]
||LN [ROW-1][2]
||LN [ROW-1][3]
||LN [ROW-1][4])/*if at least a figure of row analysed equal to a figure of jumping board row*/


I've added LN[r][c]== and I placed the test on multiple lines to highlight the difference.

The possible cause of the infinite loop would depend on the presence of r = +1 inside the loop for (r = 0; ...
I've cleared and the program stops.
i figured it out...the problem was a very simple one...r=+1 is a wrong syntax,,,it should have been r+=1, and the same thing for Numberofpossiblenum+=5..anyway thanks for your effort ;) everything worked perfectly the moment i changed that ..thanks again anyways
Topic archived. No new replies allowed.