Creating 2-dimensional array (nxn) *Pascal -


does know how create matrix using array function in pascal?

output this:

 00100 01110 11111 01110 00100 

thanks.

edit:

this code sofar:

program borlpasc; var a:array[1..100,1..100] of integer;     i,j,n:integer; begin write('enter number n='); {example: 5}    readln(n);    i:=1 n        j:=1 n            begin a[i,j]:=0;            if n mod 2 = 1 begin            a[n div 2 + 1, j] := 1;            a[i, n div 2 + 1] := 1;            end;            end;     i:=1 n         begin j:=1 n write(a[i,j]:2);             writeln         end;      readln end. 

but this:

 00100 00100 11111 00100 00100 

you don't need arrays this, 2 nested loops. here example writes grid of 1s - see if can modify give output need (hint: need add if statement).

program grid;    procedure drawgrid(nx: integer; ny: integer);      var       x, y: integer;      begin       y := 1 ny         begin           x := 1 nx             begin               write('1');             end;           writeln;         end;     end;  begin   drawgrid(5, 5); end.         

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -