I know this may sound like a very basic/dumb question. But to put an example in Pascal,
Program prueba ;
var
a : integer ;
begin
write(a) ;
end.
For example, if I were asked what the write(a) prints on the screen, what would it print?
I know this may sound like a very basic/dumb question. But to put an example in Pascal,
Program prueba ;
var
a : integer ;
begin
write(a) ;
end.
For example, if I were asked what the write(a) prints on the screen, what would it print?
The exercise asks me to: enter a quantity x of natural numbers greater than one and show on the screen the decomposition into prime factors of each one, indicate which of them has more prime factors, e.g.:
72 : 2 - 2 - 2 - 3 - 3
50 : 2 - 5 - 5
type
vec=array [0..100] of byte;
var
n,r:byte;
v,m: vec;
procedure leevec(var n : byte; var v: vec);
var
i: byte ;
begin
write('ingre la cantidad de elementos ');
readln(n);
for i:=1 to n do
begin
write(i,': ');
readln(v[i]);
end;
end;
procedure factorprimo(n: byte; var r : byte ;v: vec; var t: vec);
var
i,d:byte;
begin
for i :=1 to n do
r:=1;
while v[i] > 1 do
begin
d:=2;
while (v[i] mod d <> 0) do
d:=d+1; // son los factores primos
t[r]:=d;
r:=r+1; // contador
v[i]:=v[i] div d;
end;
end;
procedure escritura(k:byte; a:vec);
var
i:byte;
begin
for i:=1 to k do
begin
write(a[i],' ');
end;
writeln;
end;
begin
leevec(n,v);
factorprimo(n,r,v,m);
escritura(r-1,v);
end.
This is what I was able to do but as a result I get the prime factors of the last element of the vector and I still couldn't count who has the most FP.
procedure ascendentes(n,m: byte ; mat: tipomat);
var
i,j,suma: byte ;
begin
suma:=0;
i:=2;
for j:=1 to m do
begin
while (i<=n) and (mat[i,j]>mat[i-1,j]) do
begin
i:= i+1;
suma:= suma+1;
end;
end;
writeln(i,'...',suma);
if i> n then
writeln('cumple con ',suma)
else
writeln('no cumple ');
end;
// It doesn't calculate the number of columns correctly. I'm using pascal
I'm reneging on a function to remove [] from a string. I need to remove the brackets from a string, but the problem I'm having is that those [] can be anywhere in the string.
The code I am using is the following:
function quitarCorchetes(descripcion: string): String;
Begin
if descripcion <> '' then
if descripcion[1] = '[' then
descripcion := Copy(descripcion,2,Length(descripcion)-2);
Result := descripcion;
End;
This code works for strings that are "[algo adentro]"
, the problem is when the string is of type "[algo] mas descripcion"
or "descripcion [algo]".
I don't know if there is any way to do it using a regular expression or something like that. I am very new to pascal and don't have much idea.
In my installer created with Inno Setup it was necessary to check the availability of a port to install and mount a MySQL service, since if the port is in use it is necessary to change it.