Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program ex5;
- Uses Wincrt;
- Type
- tab = Array [1..40] Of Integer;
- Var
- t,v: tab;
- i,n,x,u: Integer;
- Function position (x:Integer;t:tab;n:Integer): Integer;
- Var
- i: Integer;
- Begin
- For i:=1 To n Do
- If t[i]=x Then
- position := 1;
- End;
- Begin
- Repeat
- Writeln ('Saisir N: ');
- Readln (n);
- Until n In [5..40];
- For i:=1 To n Do
- Repeat
- Write ('T[',i,']: ');
- Readln (t[i]);
- Until (t[i]>0);
- u := 1;
- x := 0;
- For i:=1 To n Do
- Begin
- u := 3*u-1;
- If position (3*u-1,t,n)<>0 Then
- Begin
- x := x+1;
- v[x] := t[i];
- End;
- End;
- If x=0 Then
- Writeln ('Aucun élément correspend à la suite')
- Else
- For i:=1 To x Do
- Writeln (v[i]);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement