Hi people.. I need help in the Pascal please

Joined
Jun 9, 2022
Messages
1
Reaction score
0
Good night people,

I am studying Pascal, and am i with a problem.
My code needs to make combinations of four numbers, from left to right but i want to prevent those combinations repeating the same thing being the numbers in positions, but worth the same thing from right to left.


Does anyone have any idea how to do that?

code:

program mistureba;
type placa = array [1..4] of integer;
var a4num : array [1..24] of placa; // a4num : array [1..24,1..4] of integer
linha : integer;
const MAXDIG = 4;
procedure mistura(input : placa; index : integer);
// input tem a série de digitos da placa
// index indica a posição que inicia o arranjo
var output : placa;
p, i : integer;
begin
if index=MAXDIG then
begin // mostra / insere a sequencia que está em input
//for i := 1 to MAXDIG do
//write(input);
//writeln;
a4num[linha] := input;
linha := linha + 1;
end
else
begin
output := input;
for p := index to MAXDIG do
begin
output[index] := input[p];
for i := index to p - 1 do
output[i + 1] := input;
for i := p + 1 to MAXDIG do
output := input;
mistura(output,index + 1);
end;
end;
end;
var //a4num : placa;
p, i : integer;
begin
linha := 1;
for i := 1 to MAXDIG do
readln(a4num[linha,i]);
mistura(a4num[linha],1);
// vou mostrar o conteúdo do meu conjunto de placas
for linha := 1 to 24 do
if [i,1] = [i,4] then
begin
for i := 1 to MAXDIG do
write(a4num[linha,i]);
writeln;
end
else
begin
writeln('0');
end;
if [i,2] = [i,3] then
begin
for i := 1 to MAXDIG do
write(a4num[linha,i]);
writeln;
end
else
begin
writeln('0');
end;
end.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Convert pascal to python 2
Hello everyone, I would need help in bioinfo please. 3
I Need Fix In Code 1
I dont get this. Please help me!! 2
HELP PLEASE 4
Code help please 4
Please help 2
Help please 8

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top