Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.54 KB | None | 0 0
  1. var
  2.   n,i:byte;
  3.   a,t:array[1..10] of integer;
  4.   j:integer;
  5. begin
  6.   repeat
  7.     write('N = '); readln(n);
  8.   until (n>1) and (n<11);
  9.   for i:=1 to n do
  10.     repeat
  11.       write('a[',i,'] = '); readln(a[i]);
  12.     until (a[i]<>0) and (abs(a[i])<30001);
  13.   for i:=1 to n do
  14.     t[i]:=0;
  15.     if a[i]>0 then begin
  16.       for j:=1 to a[i] do
  17.         if a[i] mod j=0 then t[i]:=t[i]+j;
  18.     end else begin
  19.       for j:=-1 downto a[i] do
  20.         if a[i] mod j=0 then t[i]:=t[i]+j;
  21.     end;
  22.   for i:=1 to n do
  23.     write(t[i],' ');
  24.   readln;
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement