Foro de elhacker.net

Programación => Programación General => Mensaje iniciado por: fortunacio en 31 Octubre 2012, 23:00 pm



Título: Problema sintaxis pascal
Publicado por: fortunacio en 31 Octubre 2012, 23:00 pm
Soy nuevo en pascal y creo que algo , me harian el favor de mirar el programita?

el error es en la sitaxis del array y en la del subprograma... desde ya gracias

program matriz (imput,output);

var
n,f,c:integer;
matriz:array [1..n,1..n] of integer;

function yamir (filas:integer;colum:integer):string;
var
cont,i,j:integer;

begin
cont:=0
for i:=1 to filas do
    begin
    for j 1 to colum do
        begin
        while yamir [i,i]=1 and yamir [i,j+i]=0 do
        cont:=cont+1
        end;
            end;
                end;
                if cont=(filas*colum) then
                yamir:='Matriz unidad';
                else
                yamir:='No es matriz unidad';
                end;
                begin
                     writeln('Ingrese N siendo N FILAS*COLUMNAS');
                     read(n);
                     writeln('ingrese matriz, fila por fila');
                     for f:= 1 to n do
                     begin
                          for c:= 1 to n do
                          read (matriz[f,c]);
                          end;
                          writeln('Su matriz es', yamir(f,c))
                          end.


Título: Re: Problema sintaxis pascal
Publicado por: _Enko en 31 Octubre 2012, 23:17 pm
Por lo pronto mira los bloques BEGIN-END que estan mal.


Título: Re: Problema sintaxis pascal
Publicado por: fortunacio en 31 Octubre 2012, 23:36 pm
gracias.. quedo asi:

program matriz (imput,output);

var
n,f,c:integer;
matriz:array [1..n,1..n] of integer;

function yamir (filas:integer;colum:integer):string;
var
cont,i,j:integer;

begin
cont:=0
for i:=1 to filas do
    begin
    for j 1 to colum do
        begin
        while yamir [i,i]=1 and yamir [i,j+i]=0 do
        cont:=cont+1
        end;
            end;
                end;
                if cont=(filas*colum) then
                yamir:='Matriz unidad';
                else
                yamir:='No es matriz unidad';
                end;
                begin
                     writeln('Ingrese N siendo N FILAS*COLUMNAS');
                     read(n);
                     writeln('ingrese matriz, fila por fila');
                     for f:= 1 to n do
                     begin
                          for c:= 1 to n do
                          read (matriz[f,c]);
                          end;
                          writeln('Su matriz es', yamir(f,c))
                          end
                          end.