This is going to be a time consuming long post. I apologise. But this has been a problem that has plagued me for days.
This is my grid:
Code:
...........#.#.
.#.#.#.#.#.....
...........#.#.
.#.#.#.###.#.#.
.....#.........
.#.#.#.#.###.##
I am supposed to count and number both the columns and the rows.
* Rule for Column:
There has to be 3 consecutive dots on the grid in a column.
So this is the output i should get.
Code:
1.2.3.4.5.6#7#8
.#.#.#.#.#.....
...........#.#.
9#10#11#12###.#13#.
.....#.........
.#.#.#.#.###.##
* Rule for Rows:
There has to be 3 or more consecutive dots from left to right for there to be a row (bound by hashes or end of line. Here's the output that i get.
Code:
1..........#.#.
.#.#.#.#.#2....
3..........#.#.
.#.#.#.###.#.#.
4....#5........
.#.#.#.#.###.##
Everything's cool so far. But the problem is that i need an output that is a combination of BOTH the GRIDS shown above. The Row Grid and the Column Grid. This is the output i need to get:
Code:
1.2.3.4.5.6#7#8
.#.#.#.#.#9....
10..........#.#.
11#12#13#14###.#15#.
16....#17........
.#.#.#.#.###.##
I don't know how to GET THIS output and get the numbers right.
Should i be using another array to do this? Any Help Appreciated.
Thanks guys.
Here's part of my code used to number the grids:
Code:
// For numbering COLUMNS
countcolumn = 1;
for(row=0; row<tall; row++){
for(col=0; col<wide; col++){
if ((row%3==0) && (grid[row][col]=='.') && (grid[row+1][col]=='.') && (grid[row+2][col]=='.')){
printf("%d", countcolumn++);
}
else{
printf("%c", grid[row][col]);
}
}
printf("\n");
}
printf("\n");
printf("\n");
// for Numbering ROWS.
countrow = 1;
row = 0;
col = 0;
onoroff = 0;
for(row=0; row<tall; row++){
for(col=0; col<wide; col++){
if ((grid[row][col]=='.') && (grid[row][col+1]=='.') && (grid[row][col+2]=='.')){
if (onoroff==0){
printf("%d", countrow++);
onoroff = 1;
continue;
}
printf("%c", grid[row][col]);
}
else{
printf("%c", grid[row][col]);
flag = 0;
}
}
printf("\n");
}