LOVEGUN

Application 2 (Les Algorithmes Recurrents)

Jan 14th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.65 KB | None | 0 0
  1. Program app2;
  2. Uses Wincrt;
  3. Var
  4.   a: Char;
  5.   n,i: Integer;
  6.   ch: String;
  7. Function Thue_Morse (ch:String): String;
  8. Var
  9.   x: String;
  10.   i: Integer;
  11. Begin
  12.   x := '';
  13.   For i:=1 To Length (ch) Do
  14.     Begin
  15.       If ch[i]='0' Then
  16.         x := x+'01';
  17.       If ch[i]='1' Then
  18.         x := x+'10';
  19.     End;
  20.   Thue_Morse := x;
  21. End;
  22. Begin
  23.   Repeat
  24.     Write ('Saisir A: ');
  25.     Readln (a);
  26.   Until a In ['0','1'];
  27.   Repeat
  28.     Write ('Saisir N: ');
  29.     Readln (n);
  30.   Until (0<n) And (n<30);
  31.   ch := a;
  32.   Clrscr;
  33.   Writeln ('U0->',ch);
  34.   For i:=1 To n Do
  35.     Begin
  36.       ch := Thue_Morse(ch);
  37.       Writeln ('U',i,'->',ch);
  38.     End;
  39. End.
  40.  
Advertisement
Add Comment
Please, Sign In to add comment