LOVEGUN

Bac 2009

Dec 28th, 2020 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.09 KB | None | 0 0
  1. Program bac2009;
  2. Uses Wincrt;
  3. Var
  4.   f: Text;
  5.   p,q: Longint;
  6. Procedure creation (Var f:Text);
  7. Begin
  8.   Assign (f,'C:\bac\decomp.txt');
  9. End;
  10.  
  11. Procedure saisie (Var p,q:Longint);
  12. Begin
  13.   Repeat
  14.     Writeln ('Saisir p :');
  15.     Readln (p);
  16.     Writeln ('Saisir q :');
  17.     Readln (q);
  18.   Until (10<p) And (p<q) And (q<100000);
  19. End;
  20. function facpr (i:longint):string;
  21. Var
  22.  j:longint;
  23.  ch,x:string;
  24. Begin
  25.     j:=2;
  26.     ch:='';
  27.     Repeat
  28.         if i mod j = 0 Then
  29.             Begin
  30.                 i:=i div j;
  31.                 str (j,x);
  32.                 ch:=ch+x+'.';
  33.                 j:=2;
  34.             end
  35.             else j:=j+1;
  36.     until i=1;
  37.     delete (ch,Length(ch),1);
  38.     facpr:=ch;
  39.  
  40. end;
  41. Procedure traitment (Var f:Text;p,q:Longint);
  42. Var
  43. i:longint;
  44. ch:string;
  45. Begin
  46.     rewrite (f);
  47.     writeln (f,p,' ',q);
  48.     For i:=p To q Do
  49.     Begin
  50.         ch:=facpr(i);
  51.         writeln (f,i,'=',ch);
  52.         End;
  53.         close (f);
  54. End;
  55.  
  56. Procedure affiche (Var f:Text);
  57. Var
  58.   ch: String;
  59. Begin
  60.   Reset (f);
  61.   While Not (Eof(f)) Do
  62.     Begin
  63.       Readln (f,ch);
  64.       Writeln (ch);
  65.     End;
  66.   Close (f);
  67. End;
  68. Begin
  69.   creation (f);
  70.   saisie (p,q);
  71.     traitment (f,p,q);
  72.     affiche (f);
  73. End.
  74.  
Add Comment
Please, Sign In to add comment