Advertisement
ArfIsAToe

extra+

Feb 13th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.98 KB | None | 0 0
  1. program extraplus;
  2. uses WinCrt;
  3. type
  4.     tab = array [1..100] of word ;
  5.    
  6. var
  7.     t : tab;
  8.     n,a : byte;
  9.  
  10. Procedure inpn(var n : byte);
  11.     Begin
  12.         repeat
  13.             Write('N= ');
  14.              readln(n);
  15.         Until n >= 5;
  16.     end;
  17.     Procedure rempt(var t : tab ; n : byte);
  18.         var
  19.             a : Integer;
  20.     begin
  21.             for a:=1 to n do
  22.                 t[a]:= random(9991)+10;
  23.         end;
  24.         Function vf(x,a : word ): Boolean;
  25.             var
  26.                 ch: string;
  27.                 k,b,s : Integer;
  28.             Begin  
  29.                 str(x,ch);
  30.                 s:=0;
  31.                 for b:=1 to Length(ch) do
  32.                  s:= s+ ( ord(ch[b])-ord('0') )  ;
  33.                 b:=1;
  34.                 k :=  ord(ch[b])-ord('0');
  35.                 while (b <= Length(ch) )and (k <> 0)  and (s mod k = 0 ) do
  36.                     begin
  37.                         b:=b+1;
  38.                         k :=  ord(ch[b])-ord('0');
  39.                     End;
  40.                 vf:= b > Length(ch);
  41.                
  42.             End;
  43.                 Procedure afft(t : tab ; n : Byte);
  44.                 Var
  45.                     a: word;
  46.                 begin
  47.                     for a:=1 to n do
  48.                         if VF(t[a],a) = true then
  49.                          write(t[a]:7);
  50.  
  51.                 End;
  52.        
  53.    
  54. begin
  55.     Randomize;
  56.     inpn(n);
  57.     rempt(t,n);
  58.     afft(t,n);
  59. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement