LOVEGUN

Brouillon #1

Nov 12th, 2020 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.43 KB | None | 0 0
  1. Program beta;
  2. Uses Wincrt;
  3. Type
  4.   base = Array [0..32767] Of String;
  5. Var
  6.   f: Text;
  7.   a,b: Integer;
  8.  
  9. Procedure creation (Var f:Text);
  10. Begin
  11.   Assign (f,'C:\bac\prog\Beta\Bin.txt');
  12. End;
  13.  
  14. Procedure saisie (Var a,b:Integer);
  15. Begin
  16.   Repeat
  17.     Writeln ('Saisir a et b ');
  18.     Readln (a);
  19.     Readln (b);
  20.   Until (10<a) And (a<b) And (b<10000);
  21. End;
  22.  
  23. Function distnul (i:Integer): Boolean;
  24. Var
  25.   test: Boolean;
  26.   ch: String;
  27.   j: Integer;
  28. Begin
  29.   Str (i,ch);
  30.   j := 0;
  31.   Repeat
  32.     j := j+1;
  33.     test := (ch[j]<>ch[j+1]) And ((ch[j]<>'0') And (ch[j+1]<>'0'));
  34.   Until (test=False) Or (j=Length(ch)-1);
  35.   distnul := test;
  36. End;
  37.  
  38. Function divis (i:Integer): Boolean;
  39. Var
  40.   e,j,x: Integer;
  41.   test: Boolean;
  42.   ch: String;
  43. Begin
  44.   j := 0;
  45.   Str (i,ch);
  46.   Repeat
  47.     j := j+1;
  48.     Val (ch[j],x,e);
  49.     test := i Mod x =0;
  50.   Until (test=False) Or (Length(ch)=j);
  51.   divis := test;
  52. End;
  53.  
  54. Procedure remplir (Var f:Text;a,b:Integer);
  55. Var
  56.   i: Integer;
  57. Begin
  58.   Rewrite (f);
  59.   For i:=a To b Do
  60.     If (distnul (i)) And (divis(i)) Then
  61.       Writeln (f,i,' est un nombre extraordinaire');
  62.   Close (f);
  63. End;
  64.  
  65. Procedure affiche (Var t:Text);
  66. Var
  67.   ch: String;
  68. Begin
  69.   Reset (f);
  70.   If Eof(f) Then
  71.     Writeln ('Il y''a r');
  72.   While Not (Eof(f)) Do
  73.     Begin
  74.       Readln (f,ch);
  75.       Writeln (ch);
  76.     End;
  77. End;
  78. Begin
  79.   creation (f);
  80.   saisie (a,b);
  81.   remplir (f,a,b);
  82.   affiche (f);
  83.   Close (f);
  84. End.
  85.  
Add Comment
Please, Sign In to add comment