Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library project_dll;
- { Important note about DLL memory management: ShareMem must be the
- first unit in your library's USES clause AND your project's (select
- Project-View Source) USES clause if your DLL exports any procedures or
- functions that pass strings as parameters or function results. This
- applies to all strings passed to and from your DLL--even those that
- are nested in records and classes. ShareMem is the interface unit to
- the BORLNDMM.DLL shared memory manager, which must be deployed along
- with your DLL. To avoid using BORLNDMM.DLL, pass string information
- using PChar or ShortString parameters. }
- uses
- SysUtils,
- Classes;
- {$R *.res}
- function Execute(const data: WideString): WideString; stdcall; export;
- var
- des: array of string;
- vars: array of string;
- nums: array of array of integer;
- weight: array of integer;
- i,j,k,pos1,pos2,pos3:integer;
- s:string;
- b:boolean;
- begin
- b:=false;
- pos1:=1;
- for i:=1 to length(data) do begin
- if ((ord(data[i])=13) or (ord(data[i])=10)) then begin
- if b=false then begin
- b:=true;
- setlength(des,length(des)+1);
- des[length(des)-1]:=copy(data,pos1,i-pos1);
- end;
- end
- else begin
- if b=true then begin
- b:=false;
- pos1:=i;
- end;
- end;
- end;
- setlength(weight,length(des));
- for i:=0 to length(des)-1 do begin
- j:=pos('=',des[i]);
- weight[i]:=strtoint(copy(des[i], j+1, length(des[i])-j));
- delete(des[i], j, length(des[i]));
- end;
- s:=des[0];
- while(length(s)>0) do begin
- j:=lastdelimiter('-~',s);
- setlength(vars,length(vars)+1);
- vars[length(vars)-1]:=copy(s,j+1,length(s)-j);
- if j=0 then j:=1;
- delete(s,j,length(s));
- end;
- setlength(nums,length(vars),length(vars));
- for i:=0 to length(vars)-1 do
- for j:=i+1 to length(vars)-1 do begin
- for k:=0 to length(des)-1 do begin
- pos1:=pos(vars[i],des[k]);
- pos2:=pos(vars[j],des[k]);
- if pos1>pos2 then begin
- s:=copy(des[k],pos2,pos1-pos2);
- pos3:=pos('-',s)+pos2-1;
- if pos3>0 then nums[j,i]:=nums[j,i]+weight[k];
- end
- else begin
- s:=copy(des[k],pos1,pos2-pos1);
- pos3:=pos('-',s)+pos1-1;
- if pos3>0 then nums[i,j]:=nums[i,j]+weight[k];
- end;
- end;
- end;
- for i:=0 to length(vars)-1 do begin
- b:=true;
- for j:=0 to length(vars)-1 do begin
- if i=j then continue;
- if nums[i,j]<nums[j,i] then begin
- b:=false;
- break;
- end;
- end;
- if b=true then begin
- Result:='Ëó÷øèé âàðèàíò: '+vars[i];
- break;
- end;
- end;
- pos2:=-1;
- if b=false then begin
- Result:='Îáíàðóæåí ïàðàäîêñ Êîíäîðñå';
- for i:=0 to length(vars)-1 do begin
- pos1:=0;
- for j:=0 to length(vars)-1 do pos1:=pos1+nums[i,j];
- if pos1>pos2 then begin
- s:=vars[i];
- pos2:=pos1;
- end
- else if pos1=pos2 then s:=s+', '+vars[i];
- end;
- Result:=Result+'Ëó÷øèè âàðèàíò: '+s;
- end;
- end;
- function About: WideString; stdcall; export;
- begin
- Result:='10 Ëàá | Áóêèí Í. | Êîíäîðñå';
- end;
- exports Execute, About;
- begin
- end.
Advertisement
Add Comment
Please, Sign In to add comment