Click here to Skip to main content
15,939,853 members
Home / Discussions / C#
   

C#

 
GeneralRe: Randomly Pin
Eddy Vluggen16-Dec-16 3:51
professionalEddy Vluggen16-Dec-16 3:51 
AnswerRe: Randomly Pin
Patrice T15-Dec-16 12:27
mvePatrice T15-Dec-16 12:27 
Questionhow to create dropdownlist to select country than state is automaticaly selected Pin
Member 1290578714-Dec-16 22:40
Member 1290578714-Dec-16 22:40 
AnswerRe: how to create dropdownlist to select country than state is automaticaly selected Pin
OriginalGriff14-Dec-16 22:46
mveOriginalGriff14-Dec-16 22:46 
QuestionConvert .mats file into .text file with unicode encoding Pin
ERAJEET8813-Dec-16 20:12
ERAJEET8813-Dec-16 20:12 
QuestionRe: Convert .mats file into .text file with unicode encoding Pin
Richard MacCutchan13-Dec-16 22:07
mveRichard MacCutchan13-Dec-16 22:07 
AnswerRe: Convert .mats file into .text file with unicode encoding Pin
Jochen Arndt13-Dec-16 22:38
professionalJochen Arndt13-Dec-16 22:38 
QuestionPascal to C# Convert Pin
Pavlex413-Dec-16 7:59
Pavlex413-Dec-16 7:59 
How to convert this pascal code in C# :

Delphi
uses crt;
var najbl:int64;
    u,pok,zad,a:longint;
    l:integer;
    niz:array[1..946686] of int64;
    uzet:array[1..6] of boolean;
    w:string;
    lpl:boolean;
function abs(x:int64):int64;
begin
 if x>0 then abs:=x
        else abs:=-x;
end;
function num2str(y:integer):string;
begin
 num2str:='';
 repeat
  num2str:=chr(y mod 10+48)+num2str;
  y:=y div 10
 until y=0;
end;
procedure inc_uzet;
var ss:byte;
begin
 for ss:=1 to 6 do
   uzet[ss]:=false;
end;
procedure oznaci_po_redu(s:integer);
begin
 l:=0;
 while (s>0) do
    begin
     inc(l);
     if not(uzet[l]) then dec(s);
    end;
 uzet[l]:=true;
end;
procedure dekodiraj(i:longint);
begin
 if i<7 then uzet[i]:=true
        else if i<127 then begin
                            dekodiraj((i-7) div 4 div 5 + 1);
                            oznaci_po_redu((i-7) div 4 - (i-7) div 4 div 5 * 5 + 1);
                           end
        else if i<2047 then begin
                             dekodiraj((i-127) div 4 div 4 + 7);
                             oznaci_po_redu((i-127) div 4 - (i-127) div 4 div 4 * 4 + 1);
                            end
        else if i<25087 then begin
                              dekodiraj((i-2047) div 4 div 3 + 127);
                              oznaci_po_redu((i-2047) div 4 - (i-2047) div 4 div 3 * 3 + 1);
                             end
        else if i<209407 then begin
                               dekodiraj((i-25087) div 4 div 2 + 2047);
                               oznaci_po_redu((i-25087) div 4 - (i-25087) div 4 div 2 * 2 + 1);
                              end
        else begin
              dekodiraj((i-209407)div 4 + 25087);
              oznaci_po_redu(1);
             end;
end;
procedure dekodiraj1(i:longint);
var a:longint;
begin
 if i<7 then begin
              uzet[i]:=true;
              w:=w+num2str(niz[i]);
              lpl:=false;
             end
        else begin
              if i<127 then begin
                             a:=(i-7) div 4 div 5 + 1;
                             dekodiraj1(a);
                             oznaci_po_redu((i-7) div 4 - 5*(a-1)+1);
                            end
                       else if i<2047 then begin
                                            a:=(i-127) div 4 div 4 + 7;
                                            dekodiraj1(a);
                                            oznaci_po_redu((i-127) div 4 - 4*(a-7)+1);
                                           end
                       else if i<25087 then begin
                                             a:=(i-2047) div 4 div 3 + 127;
                                             dekodiraj1(a);
                                             oznaci_po_redu((i-2047) div 4 - 3*(a-127)+1);
                                            end
                       else if i<209407 then begin
                                              a:=(i-25087) div 4 div 2 + 2047;
                                              dekodiraj1(a);
                                              oznaci_po_redu((i-25087) div 4 - 2*(a-2047)+1);
                                             end
                       else begin
                             a:=(i-209407)div 4 + 25087;
                             dekodiraj1(a);
                             oznaci_po_redu(1);
                            end;
              case ((i+1) mod 4) of
                0: begin
                    w:=w+'+'+num2str(niz[l]);
                    lpl:=true;
                   end;
                1: begin
                    if niz[a]>niz[l] then begin
                                           w:=w+'-'+num2str(niz[l]);
                                          end
                                     else begin
                                           if not(lpl) then w:=num2str(niz[l])+'-'+w
                                                       else w:=num2str(niz[l])+'-('+w+')';
                                          end;
                    lpl:=true;
                   end;
                2: begin
                    if lpl then w:='('+w+')*'+num2str(niz[l])
                           else w:=w+'*'+num2str(niz[l]);
                    lpl:=false;
                   end;
                3: begin
                    if niz[a]>niz[l] then begin
                                           if lpl then w:='('+w+')/'+num2str(niz[l])
                                                  else w:=w+'/'+num2str(niz[l]);
                                          end
                                     else begin
                                           if i<127 then w:=num2str(niz[l])+'/'+w
                                                    else w:=num2str(niz[l])+'/('+w+')';
                                          end;
                    lpl:=false;
                   end;
              end;
             end;
end;
procedure ispisi;
begin
 writeln(zad);
 writeln(w);
 repeat until keypressed;
 halt(0);
end;
procedure kraj;
begin
 if niz[pok]=zad then begin
                       inc_uzet;
                       dekodiraj1(pok);
                       ispisi;
                      end;
end;
procedure uradi(k:longint);
var j:integer;
begin
 inc_uzet;
 dekodiraj(k);
 for j:=1 to 6 do
   if not(uzet[j]) then begin
                         niz[pok]:=niz[k]+niz[j];
                         kraj;
                         inc(pok);
                         niz[pok]:=abs(niz[k]-niz[j]);
                         kraj;
                         inc(pok);
                         niz[pok]:=niz[k]*niz[j];
                         kraj;
                         inc(pok);
                         niz[pok]:=0;
                         if niz[k] mod niz[j]=0 then niz[pok]:=niz[k] div niz[j]
                                                else if niz[k]>0 then if niz[j] mod niz[k]=0 then niz[pok]:=niz[j] div niz[k];
                         kraj;
                         inc(pok);
                        end;
end;
procedure resi_6;
begin
 for u:=1 to 946686 do
   if abs(niz[u]-zad)<abs(najbl-zad) then begin
                                           najbl:=niz[u];
                                           pok:=u;
                                          end;
 inc_uzet;
 dekodiraj1(pok);
 if najbl=zad then ispisi;
end;
procedure resi_3_3;
var v:longint;
    w1:string;
    uzet1:array[1..6] of boolean;
begin
 for u:=7 to 2045 do
   for v:=u+1 to 2046 do
     begin
      inc_uzet;
      dekodiraj(v);
      for pok:=1 to 6 do
        uzet1[pok]:=uzet[pok];
      inc_uzet;
      dekodiraj(u);
      if not((uzet[1] and uzet1[1])or(uzet[2] and uzet1[2])or(uzet[3] and uzet1[3])or(uzet[4] and uzet1[4])or(uzet[5] and uzet1[5])or(uzet[6] and uzet1[6]))
           then begin
                 if abs(niz[u]+niz[v]-zad)<abs(najbl-zad) then begin
                                                                najbl:=niz[u]+niz[v];
                                                                w:='';
                                                                inc_uzet;
                                                                dekodiraj1(v);
                                                                w1:=w;
                                                                w:='';
                                                                inc_uzet;
                                                                dekodiraj1(u);
                                                                w:=w+'+'+w1;
                                                                if najbl=zad then ispisi;
                                                               end;
                 if abs(abs(niz[u]-niz[v])-zad)<abs(najbl-zad) then begin
                                                                     najbl:=abs(niz[u]-niz[v]);
                                                                     w:='';
                                                                     inc_uzet;
                                                                     if niz[u]>niz[v] then begin
                                                                                            dekodiraj1(v);
                                                                                            if lpl then w1:='('+w+')'
                                                                                                   else w1:=w;
                                                                                            w:='';
                                                                                            inc_uzet;
                                                                                            dekodiraj1(u);
                                                                                           end
                                                                                      else begin
                                                                                            dekodiraj1(u);
                                                                                            if lpl then w1:='('+w+')'
                                                                                                   else w1:=w;
                                                                                            w:='';
                                                                                            inc_uzet;
                                                                                            dekodiraj1(v);
                                                                                           end;
                                                                     w:=w+'-'+w1;
                                                                     if najbl=zad then ispisi;
                                                                    end;
                 if abs(niz[u]*niz[v]-zad)<abs(najbl-zad) then begin
                                                                najbl:=niz[u]*niz[v];
                                                                w:='';
                                                                inc_uzet;
                                                                dekodiraj1(v);
                                                                if lpl then w1:='('+w+')'
                                                                       else w1:=w;
                                                                w:='';
                                                                inc_uzet;
                                                                dekodiraj1(u);
                                                                if lpl then w:='('+w+')*'+w1
                                                                       else w:=w+'*'+w1;
                                                                if najbl=zad then ispisi;
                                                               end;
                 if (niz[v]>0) and (niz[u] mod niz[v]=0) then
                 if abs(niz[u] div niz[v]-zad)<abs(najbl-zad) then begin
                                                                    najbl:=niz[u] div niz[v];
                                                                    w:='';
                                                                    inc_uzet;
                                                                    dekodiraj1(v);
                                                                    w1:='('+w+')';
                                                                    w:='';
                                                                    inc_uzet;
                                                                    dekodiraj1(u);
                                                                    if lpl then w:='('+w+')/'+w1
                                                                           else w:=w+'/'+w1;
                                                                    if najbl=zad then ispisi;
                                                                   end
                                                              else
                                                         else
                 if (niz[u]>0) and (niz[v] mod niz[u]=0) then
                 if abs(niz[v] div niz[u]-zad)<abs(najbl-zad) then begin
                                                                    najbl:=niz[v] div niz[u];
                                                                    w:='';
                                                                    inc_uzet;
                                                                    dekodiraj1(u);
                                                                    w1:='('+w+')';
                                                                    w:='';
                                                                    inc_uzet;
                                                                    dekodiraj1(v);
                                                                    if lpl then w:='('+w+')/'+w1
                                                                           else w:=w+'/'+w1;
                                                                    if najbl=zad then ispisi;
                                                                   end;
                end;
     end;
end;
procedure resi_2_2_2;
var v,v1:longint;
    w1:string;
    uzet1:array[1..6] of boolean;
begin
 for u:=7 to 126 do
   for v:=7 to 126 do
     begin
      inc_uzet;
      dekodiraj(v);
      for pok:=1 to 6 do
        uzet1[pok]:=uzet[pok];
      inc_uzet;
      dekodiraj(u);
      if not((uzet[1] and uzet1[1])or(uzet[2] and uzet1[2])or(uzet[3] and uzet1[3])or(uzet[4] and uzet1[4])or(uzet[5] and uzet1[5])or(uzet[6] and uzet1[6]))
           then begin
                 for pok:=1 to 6 do
                   uzet1[pok]:=uzet[pok] or uzet1[pok];
                 for v1:=1 to 126 do
                   begin
                    inc_uzet;
                    dekodiraj(v1);
                    if not((uzet[1] and uzet1[1])or(uzet[2] and uzet1[2])or(uzet[3] and uzet1[3])or(uzet[4] and uzet1[4])or(uzet[5] and uzet1[5])or(uzet[6] and uzet1[6]))
                         then begin
//prvu dvojicu sabiramo
                               if abs(niz[u]+niz[v]+niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[u]+niz[v]+niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      w1:=w+'+'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      w:=w+'+'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs(abs(niz[u]+niz[v]-niz[v1])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[u]+niz[v]-niz[v1]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u]+niz[v]>niz[v1] then begin
                                                                                                                     dekodiraj1(v1);
                                                                                                                     if lpl then w1:='('+w+')'
                                                                                                                            else w1:=w;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(v);
                                                                                                                     w1:=w+'-'+w1;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(u);
                                                                                                                     w:=w+'+'+w1;
                                                                                                                    end
                                                                                                               else begin
                                                                                                                     dekodiraj1(v);
                                                                                                                     w1:=w;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(u);
                                                                                                                     w1:='('+w+'+'+w1+')';
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(v1);
                                                                                                                     w:=w+'-'+w1;
                                                                                                                    end;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs((niz[u]+niz[v])*niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=(niz[u]+niz[v])*niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w1:='('+w+')'
                                                                                             else w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      w1:=w+')*'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      w:='('+w+'+'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if (niz[v1]>0) and ((niz[u]+niz[v]) mod niz[v1]=0) then
                               if abs((niz[u]+niz[v]) div niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=(niz[u]+niz[v]) div niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if v1<7 then w1:=w
                                                                                              else w1:='('+w+')';
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      w1:=w+')/'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      w:='('+w+'+'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end
                                                                                      else
                                                                                  else
                               if (niz[u]+niz[v]>0) and (niz[v1] mod (niz[u]+niz[v])=0) then
                               if abs(niz[v1] div (niz[u]+niz[v])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[v] div (niz[u]+niz[v]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      w1:=w+')';
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      w1:='('+w+'+'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w:='('+w+')/'+w1
                                                                                             else w:=w+'/'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
//prvu dvojicu oduzimamo
                               if abs(abs(niz[u]-niz[v])*niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[u]-niz[v])*niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w1:='('+w+')'
                                                                                             else w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u]>niz[v] then begin
                                                                                                             dekodiraj1(v);
                                                                                                             if lpl then w1:='('+w+'))*'+w1
                                                                                                                    else w1:=w+')*'+w1;
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(u);
                                                                                                            end
                                                                                                       else begin
                                                                                                             dekodiraj1(u);
                                                                                                             if lpl then w1:='('+w+'))*'+w1
                                                                                                                    else w1:=w+')*'+w1;
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(v);
                                                                                                            end;
                                                                                      w:='('+w+'-'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if (niz[v1]>0) and (abs(niz[u]-niz[v]) mod niz[v1]=0) then
                               if abs(abs(niz[u]-niz[v]) div niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[u]-niz[v]) div niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if v1<7 then w1:=w
                                                                                              else w1:='('+w+')';
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u]>niz[v] then begin
                                                                                                             dekodiraj1(v);
                                                                                                             if lpl then w1:='('+w+'))/'+w1
                                                                                                                    else w1:=w+')/'+w1;
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(u);
                                                                                                            end
                                                                                                       else begin
                                                                                                             dekodiraj1(u);
                                                                                                             if lpl then w1:='('+w+'))/'+w1
                                                                                                                    else w1:=w+')/'+w1;
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(v);
                                                                                                            end;
                                                                                      w:='('+w+'-'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end
                                                                                      else
                                                                                  else
                               if (abs(niz[u]-niz[v])>0) and (niz[v1] mod abs(niz[u]-niz[v])=0) then
                               if abs(niz[v1] div abs(niz[u]-niz[v])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[v1] div abs(niz[u]-niz[v]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u]>niz[v] then begin
                                                                                                             dekodiraj1(v);
                                                                                                             if lpl then w1:='('+w+'))'
                                                                                                                    else w1:=w+')';
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(u);
                                                                                                            end
                                                                                                       else begin
                                                                                                             dekodiraj1(u);
                                                                                                             if lpl then w1:='('+w+'))'
                                                                                                                    else w1:=w+')';
                                                                                                             w:='';
                                                                                                             inc_uzet;
                                                                                                             dekodiraj1(v);
                                                                                                            end;
                                                                                      w1:='('+w+'-'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w:='('+w+')/'+w1
                                                                                             else w:=w+'/'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
//prvu dvojicu mnozimo
                               if abs(niz[u]*niz[v]+niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[u]*niz[v]+niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      if lpl then w1:='('+w+')+'+w1
                                                                                             else w1:=w+'+'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      if lpl then w:='('+w+')*'+w1
                                                                                             else w:=w+'*'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs(abs(niz[u]*niz[v]-niz[v1])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[u]*niz[v]-niz[v1]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u]*niz[v]>niz[v1] then begin
                                                                                                                     dekodiraj1(v1);
                                                                                                                     if lpl then w1:='('+w+')'
                                                                                                                            else w1:=w;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(v);
                                                                                                                     if lpl then w1:='('+w+')-'+w1
                                                                                                                            else w1:=w+'-'+w1;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(u);
                                                                                                                     if lpl then w:='('+w+')*'+w1
                                                                                                                            else w:=w+'*'+w1;
                                                                                                                    end
                                                                                                               else begin
                                                                                                                     dekodiraj1(v);
                                                                                                                     if lpl then w1:='('+w+')'
                                                                                                                            else w1:=w;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(u);
                                                                                                                     if lpl then w1:='('+w+')*'+w1
                                                                                                                            else w1:=w+'*'+w1;
                                                                                                                     w:='';
                                                                                                                     inc_uzet;
                                                                                                                     dekodiraj1(v1);
                                                                                                                     w:=w+'-'+w1;
                                                                                                                    end;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs(niz[u]*niz[v]*niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[u]*niz[v]*niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w1:='('+w+')'
                                                                                             else w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      if lpl then w1:='('+w+')*'+w1
                                                                                             else w1:=w+'*'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      if lpl then w:='('+w+')*'+w1
                                                                                             else w:=w+'*'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if (niz[v1]>0) and (niz[u]*niz[v] mod niz[v1]=0) then
                               if abs(niz[u]*niz[v] div niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[u]*niz[v] div niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if v1<7 then w1:=w
                                                                                              else w1:='('+w+')';
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      if lpl then w1:='('+w+')/'+w1
                                                                                             else w1:=w+'/'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      if lpl then w:='('+w+')*'+w1
                                                                                             else w:=w+'*'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end
                                                                                      else
                                                                                  else
                               if (niz[u]*niz[v]>0) and (niz[v1] mod (niz[u]*niz[v])=0) then
                               if abs(niz[v1] div (niz[u]*niz[v])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[v] div (niz[u]*niz[v]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      if lpl then w1:='('+w+'))'
                                                                                             else w1:=w+')';
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      if lpl then w1:='(('+w+')*'+w1
                                                                                             else w1:='('+w+'*'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      if lpl then w:='('+w+')/'+w1
                                                                                             else w:=w+'/'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
//prvu dvojicu delimo
                               if (niz[v]>0) and (niz[u] mod niz[v]=0) then
                              begin
                               if abs(niz[u] div niz[v]+niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[u] div niz[v]+niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      w1:='('+w+')+'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      if lpl then w:='('+w+')/'+w1
                                                                                             else w:=w+'/'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs(abs(niz[u] div niz[v]-niz[v1])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[u] div niz[v]-niz[v1]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[u] div niz[v]>niz[v1] then begin
                                                                                                                         dekodiraj1(v1);
                                                                                                                         if lpl then w1:='('+w+')'
                                                                                                                                else w1:=w;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(v);
                                                                                                                         w1:='('+w+')-'+w1;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(u);
                                                                                                                         if lpl then w:='('+w+')/'+w1
                                                                                                                                else w:=w+'/'+w1;
                                                                                                                        end
                                                                                                                   else begin
                                                                                                                         dekodiraj1(v);
                                                                                                                         w1:='('+w+')';
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(u);
                                                                                                                         if lpl then w1:='('+w+')/'+w1
                                                                                                                                else w1:=w+'/'+w1;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(v1);
                                                                                                                         w:=w+'-'+w1;
                                                                                                                        end;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                              end
                         else if (niz[u]>0) and (niz[v] mod niz[u]=0) then
                              begin
                               if abs(niz[v] div niz[u]+niz[v1]-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=niz[v] div niz[u]+niz[v1];
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v1);
                                                                                      w1:=w;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(u);
                                                                                      w1:='('+w+')+'+w1;
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      dekodiraj1(v);
                                                                                      if lpl then w:='('+w+')/'+w1
                                                                                             else w:=w+'/'+w1;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                               if abs(abs(niz[v] div niz[u]-niz[v1])-zad)<abs(najbl-zad) then begin
                                                                                      najbl:=abs(niz[v] div niz[u]-niz[v1]);
                                                                                      w:='';
                                                                                      inc_uzet;
                                                                                      if niz[v] div niz[u]>niz[v1] then begin
                                                                                                                         dekodiraj1(v1);
                                                                                                                         if lpl then w1:='('+w+')'
                                                                                                                                else w1:=w;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(u);
                                                                                                                         w1:='('+w+')-'+w1;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(v);
                                                                                                                         if lpl then w:='('+w+')/'+w1
                                                                                                                                else w:=w+'/'+w1;
                                                                                                                        end
                                                                                                                   else begin
                                                                                                                         dekodiraj1(u);
                                                                                                                         w1:='('+w+')';
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(v);
                                                                                                                         if lpl then w1:='('+w+')/'+w1
                                                                                                                                else w1:=w+'/'+w1;
                                                                                                                         w:='';
                                                                                                                         inc_uzet;
                                                                                                                         dekodiraj1(v1);
                                                                                                                         w:=w+'-'+w1;
                                                                                                                        end;
                                                                                      if najbl=zad then ispisi;
                                                                                     end;
                              end;
                              end;
                   end;
                end;
     end;
end;
begin
 readln(zad);
 for u:=1 to 6 do
   begin
    read(niz[u]);
    if niz[u]=zad then begin
                        writeln(zad);
                        writeln(zad);
                        repeat until keypressed;
                        halt(0);
                       end;
   end;
 pok:=7;
 w:='';
 for u:=1 to 209406 do
   uradi(u);
 najbl:=0;
 resi_6;
 resi_3_3;
 resi_2_2_2;
 writeln(najbl);
 writeln(w);
 repeat until keypressed;
end.

AnswerRe: Pascal to C# Convert Pin
Richard Deeming13-Dec-16 8:06
mveRichard Deeming13-Dec-16 8:06 
GeneralRe: Pascal to C# Convert Pin
Pavlex413-Dec-16 8:12
Pavlex413-Dec-16 8:12 
AnswerRe: Pascal to C# Convert Pin
OriginalGriff13-Dec-16 8:12
mveOriginalGriff13-Dec-16 8:12 
GeneralRe: Pascal to C# Convert Pin
PIEBALDconsult13-Dec-16 9:06
mvePIEBALDconsult13-Dec-16 9:06 
GeneralRe: Pascal to C# Convert Pin
NotPolitcallyCorrect13-Dec-16 9:26
NotPolitcallyCorrect13-Dec-16 9:26 
GeneralRe: Pascal to C# Convert Pin
Daniel Pfeffer13-Dec-16 20:24
professionalDaniel Pfeffer13-Dec-16 20:24 
GeneralRe: Pascal to C# Convert Pin
OriginalGriff13-Dec-16 21:41
mveOriginalGriff13-Dec-16 21:41 
QuestionRe: Pascal to C# Convert Pin
Gerry Schmitz13-Dec-16 22:27
mveGerry Schmitz13-Dec-16 22:27 
QuestionHow to Draw tracking Line of plane in Radar - C# Pin
Khant Nyar Kyaw13-Dec-16 7:51
Khant Nyar Kyaw13-Dec-16 7:51 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
OriginalGriff13-Dec-16 8:06
mveOriginalGriff13-Dec-16 8:06 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
Dave Kreskowiak13-Dec-16 9:00
mveDave Kreskowiak13-Dec-16 9:00 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
V.13-Dec-16 19:01
professionalV.13-Dec-16 19:01 
AnswerRe: How to Draw tracking Line of plane in Radar - C# Pin
Gerry Schmitz13-Dec-16 22:20
mveGerry Schmitz13-Dec-16 22:20 
Questionfingerprint transaction system Pin
Member 1290211313-Dec-16 2:45
Member 1290211313-Dec-16 2:45 
AnswerRe: fingerprint transaction system Pin
OriginalGriff13-Dec-16 2:46
mveOriginalGriff13-Dec-16 2:46 
AnswerRe: fingerprint transaction system Pin
Pete O'Hanlon13-Dec-16 2:50
mvePete O'Hanlon13-Dec-16 2:50 
AnswerRe: fingerprint transaction system Pin
Simon_Whale13-Dec-16 3:14
Simon_Whale13-Dec-16 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.