Advertisement
LOVEGUN

Brouillon #2

Mar 4th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.14 KB | None | 0 0
  1. Program bac;
  2. Uses Wincrt;
  3. function puis (a,b:integer):integer;
  4. var
  5. i,x:integer;
  6. Begin
  7. x:=a;
  8. for i:=1 to b-1 Do
  9.     a:=a*x;
  10. puis:=a;
  11. end;
  12. function calcul (ch:string):integer;
  13. Var
  14. s,a,b,e:integer;
  15. Begin
  16.     s:=1;
  17.     ch:=ch+'*';
  18.     Repeat
  19.         val (copy(ch,1,pos('_',ch)-1),a,e);
  20.         val (copy(ch,pos('_',ch)+1,pos('*',ch)-pos('_',ch)-1),b,e);
  21.         s:=s*puis(a,b);
  22.         delete (ch,1,pos('*',ch));
  23.     Until (ch='');
  24.     calcul:=s;
  25. end;
  26. Function repet (c:Char;ch:String): String;
  27. Var
  28.   i,s: Integer;
  29. Begin
  30.   s := 0;
  31.   For i:=1 To Length(ch) Do
  32.     If ch[i]=c Then
  33.       s := s+1;
  34.   Str (s,ch);
  35.   repet := ch;
  36. End;
  37.  
  38. Function facteur (a:Integer): String;
  39. Var
  40.   i,e,x: Integer;
  41.   ch,ch1: String;
  42. Begin
  43.   i := 1;
  44.   ch1 := '';
  45.   Repeat
  46.     i := i+1;
  47.     If a Mod i =0 Then
  48.       Begin
  49.         a := a Div i;
  50.         Str(i,ch);
  51.         ch1 := ch1+ch+'*';
  52.         i := 1;
  53.       End;
  54.   Until (a Div i=0);
  55.   ch := '';
  56.   Repeat
  57.     ch := ch+ch1[1]+'_'+repet(ch1[1],ch1)+'*';
  58.     Val (repet(ch1[1],ch1),x,e);
  59.     Delete (ch1,1,x*2);
  60.   Until (ch1='');
  61.   Delete (ch,Length(ch),1);
  62.   facteur := ch;
  63. End;
  64. Begin
  65.   writeln (calcul(facteur (168)));
  66. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement