Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program challenge21;
- uses crt;
- type vetor= array[1..6]of integer;
- var
- show: integer;
- vet:vetor;
- {funcao que verifica o número repetido}
- function repetido(v:vetor):integer;
- var i,j:integer;
- achou:boolean;
- begin
- i:=1;
- j:=2;
- achou:=false;
- while (not achou) and (i<=6) and (j<=6) do
- begin
- if v[i]=v[j] then
- achou:=true
- else
- j:=j+1;
- if j=7 then
- begin
- i:=i+1;
- j:=i+j;
- end;
- end;
- if achou then
- repetido:=v[i]
- else
- repetido:=-1;
- end;
- {inicio do programa principal}
- BEGIN
- vet[1]:=1;
- vet[2]:=2;
- vet[3]:=3;
- vet[4]:=4;
- vet[5]:=1;
- vet[6]:=5;
- clrscr;
- show:=repetido(vet);
- textcolor(red);
- gotoxy(25,10);
- if show<>-1 then
- writeln('O Número Repetido do Vetor é ',show)
- else
- writeln('Nao ha numeros repetidos');
- readln;
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement