Advertisement
LOVEGUN

Night Coding (Yahya suite)

Feb 6th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.29 KB | None | 0 0
  1. Program suite;
  2. Uses Wincrt;
  3. Var
  4.   f: Text;
  5.  
  6. Procedure creation (Var f:Text);
  7. Begin
  8.   Assign (f,'c:\bac\Suite.txt');
  9. End;
  10.  
  11. function max (m:Integer): Integer;
  12. Var
  13.   i,n,x1,x2,e: Integer;
  14.   echange: Boolean;
  15.     ch:string;
  16.     aux:char;
  17. Begin
  18.     str(m,ch);
  19.     n := Length(ch);
  20.   Repeat
  21.     echange := False;
  22.     For i:=1 To n-1 Do
  23.       Begin
  24.         Val (ch[i],x1,e);
  25.         Val (ch[i+1],x2,e);
  26.         If x1<x2 Then
  27.           Begin
  28.             aux := ch[i];
  29.             ch[i] := ch[i+1];
  30.             ch[i+1] := aux;
  31.             echange := True;
  32.           End;
  33.       End;
  34.     n := n-1;
  35.   Until echange= False;
  36. val (ch,x1,e);
  37. max:=x1;
  38.  
  39. End;
  40. function invers (n:integer):integer;
  41. Var
  42. ch,ch1:string;
  43. e,i:integer;
  44. Begin
  45. str (n,ch);
  46. ch1:='';
  47. for i:=Length(ch) DownTo 1 Do
  48.     ch1:=ch1+ch[i];
  49. val (ch1,n,e);
  50. invers:=n;
  51. end;
  52. Procedure traitement (Var f:Text);
  53. Var
  54.   u,i: Integer;
  55.   t: Array [1..50] Of Integer;
  56. Begin
  57.   Rewrite (f);
  58.   Writeln ('Saisir le premier terme U0');
  59.   Readln (u);
  60.   Writeln (f,u);
  61.     t[1] := max(u)-invers(max(u));
  62.   i := 1;
  63.       Repeat
  64.     i := i+1;
  65.     t[i] := max(t[i-1])-invers(max(t[i-1]));
  66.     Writeln (f,t[i]);
  67.   Until max(t[i-1])-invers(max(t[i-1]))=max(t[i])-invers(max(t[i]));
  68.     close (f);
  69. End;
  70. Begin
  71.   creation (f);
  72.   traitement (f);
  73. End.
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement