c++ - Creating a 3x3 box inside a looped grid -


I have a project for the school. I created a grid which looks like this: 0000000000000000000000000000000000000000000000000000000000000000000000 0000000000 0000000000 0000000000

Use of the following loop: Pre> IIM [10] [10]; For (int i = 0; i & lt; 10; i ++) {for (int j = 0; j & lt; 10; j ++) {img [i] [j] = 0; }}

I want to receive it: <00p> My attempt code (I have known wrongly since)

  int img [10] ] [10]; Int startRow, startCol, width, height, color; StartRow = 2; StartCol = 3; Width = 3; Height = 3; For color = 1 (int i = 0; i & lt; 10; i ++) {for (int j = 0; j & lt; 10; j ++) {img [startrow] [] = width + i ; // wrong IMG [Start] [startCol] = height + i; // what i am doing img [i + width] [j + height] = color; // program crashes}}   

This does not work How to get it, I'm losing it on.

Any help on this will be great

Definitely use this code The tax grid is made initially:

  int img [10] [10]; For (int i = 0; i & lt; 10; i ++) {for (int j = 0; j & lt; 10; j ++) {img [i] [j] = 0; }}   

and not this:

  img [i] [j] = j;   

I just add this second loop (runs after the first time):

 for  (int i = 1; i < = 3; i ++) {for (int j = 2; j and lt; = 4; j ++) {img [i] [j] = 1; }}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -