Aug 25, 2013 at 5:44am UTC
Hi, I have tried to work this out for myself, could someone point me in the right direction.
I have
#define LessSymbol -1
#define MoreSymbol 1
#define NeitherSymbol 0
#define MAX_COLS 20
#define MAX_ROWS 20
#define MAX_CHAR 3
char averageMap[MAX_ROWS][MAX_COLS];
char rowCount[MAX_ROWS][MAX_CHAR];
char colCount[MAX_COLS][MAX_CHAR];
I have other stuff in the code, but basicly, at this stage i have a map of 1's,-1's and 0's in a 20 x 20 map. I just want to count the occurrences of each and basicly tally them in the 3 colums/rows at the end of the bloc. so far ive tried many different if statements, here is what i tried last. please point me in the right direction as to what im doing wrong.
for(row = 0; row < MAX_ROWS; row++){
rowCount[row][0]=0;
rowCount[row][1]=0;
rowCount[row][2]=0;
}
for(col = 0; col < MAX_COLS; col++){
colCount[col][0]=0;
colCount[col][1]=0;
colCount[col][2]=0;
}
for(row = 0; row < MAX_ROWS; row++){
for(col = 0; col < MAX_COLS; col++){
if (averageMap[row][col]=MoreSymbol)
rowCount[row][0]=rowCount[row][0]+1;
else if (rawData[row][col]=LessSymbol)
rowCount[row][1]=rowCount[row][1]+1;
else if (rawData[row][col]=NeitherSymbol)
rowCount[row][2]=rowCount[row][2]+1;
}
{
printf("%d",rowCount[row][0]);
}
printf("\n");
}
Its outputting 20 as a result for each row. Its like its counting the symbol no matter what it is.
Thnx for any help
Aug 25, 2013 at 5:58am UTC
= is assignment. == is comparison.
Aug 25, 2013 at 6:05am UTC
You are, a god dahm legend. Thank you very very much