daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8.   System.SysUtils;
  9.  
  10. var
  11.   w: array[0..1000] of integer;
  12.   i,N,P,K,sum: integer;
  13. begin
  14.   sum:= 0;
  15.   writeln('N=');
  16.   readln(N);
  17.   writeln('K=');
  18.   readln(K);
  19.   inc(K);
  20.   writeln('P=');
  21.   readln(P);
  22.  
  23.   for i := 0 to N-1 do
  24.                     begin
  25.                       w[i]:= Random(k);
  26.                       writeln(w[i]);
  27.                       if w[i]<K then
  28.                                 begin
  29.                                    if (sum + w[i]) < P then
  30.                                                        begin
  31.                                                         sum:= sum + w[i];
  32.                                                        end;
  33.                                 end;
  34.                     end;
  35.   writeln('sum = ', sum);
  36.   Readln;
  37. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top