تبلیغات :
آکوستیک ، فوم شانه تخم مرغی، صداگیر ماینر ، یونولیت
دستگاه جوجه کشی حرفه ای
فروش آنلاین لباس کودک
خرید فالوور ایرانی
خرید فالوور اینستاگرام
خرید ممبر تلگرام

[ + افزودن آگهی متنی جدید ]




نمايش نتايج 1 به 2 از 2

نام تاپيک: خطایابی سورس هشت وزیر به زبان پاسکال

  1. #1
    در آغاز فعالیت
    تاريخ عضويت
    Nov 2006
    پست ها
    13

    پيش فرض خطایابی سورس هشت وزیر به زبان پاسکال

    این سورس را از همین قسمت گرفتم کی می تونه خطاشو در بیاره اگه بمن بگه که درستش کنم ممنون می شم
    procedure ListEightQueenPositions;
    var
    Queens: array[1..8] of Integer; (* Holds the column number of each queen *)
    NumPos: Integer;
    Q, N: Integer;
    SafePos: Boolean;
    begin
    (* Set position of all queens to undefined *)
    for Q := 1 to 8 do
    Queens[Q] := 0;
    (* Set the number of found positions to zero *)
    NumPos := 0;
    (* Start by positioning the first queen *)
    Q := 1;
    (* While there's any possible position *)
    while (Q <> 1) or (Queens[1] <> 8) do
    begin
    SafePos := False;
    (* while a non-conflict position for the current queen has not found *)
    while (Queens[Q] < 8) and not SafePos do
    begin
    (* Advance one colume the position of the queen *)
    Queens[Q] := Queens[Q] + 1;
    (* Check whether this column has any confilict with the the other queens *)
    SafePos := True;
    N := 1;
    while (N < Q) and SafePos do
    begin
    (* Two queens are not in confilict with each other when *)
    SafePos :=
    (* They are not on the same column, and *)
    (Queens[N] <> Queens[Q]) and
    (* They are not on the same oblique line *)
    (Abs(Queens[N] - Queens[Q]) <> Abs(N - Q));
    (* Check with another queen *)
    N := N + 1;
    end;
    end;
    (* If there was a non-coflict position for the current queen *)
    if SafePos then
    begin
    (* If it is the last queen *)
    if Q = 8 then
    begin
    (* Increase the number of found positions by one *)
    NumPos := NumPos + 1;
    (* Print out the position of queens *)
    Write(NumPos:2, ' -> ');
    for N := 1 to 8 do
    Write('(', N:1, ',', Queens[N]:1, ') ');
    Writeln;
    end
    else
    begin
    (* Continue with the next queen *)
    Q := Q + 1;
    end;
    end
    else
    begin
    (* Set the position of the current queen undefined *)
    Queens[Q] := 0;
    (* Reposition the previous queen *)
    Q := Q - 1;
    end;
    end;
    end;

  2. #2
    مدیر انجمن برنامه نویسی Payman_62's Avatar
    تاريخ عضويت
    Dec 2005
    محل سكونت
    تهران
    پست ها
    2,445

    پيش فرض

    سلام.
    لطفا سوالتون رو در بخش مربوطه مطرح کنید.

Thread Information

Users Browsing this Thread

هم اکنون 1 کاربر در حال مشاهده این تاپیک میباشد. (0 کاربر عضو شده و 1 مهمان)

User Tag List

قوانين ايجاد تاپيک در انجمن

  • شما نمی توانید تاپیک ایحاد کنید
  • شما نمی توانید پاسخی ارسال کنید
  • شما نمی توانید فایل پیوست کنید
  • شما نمی توانید پاسخ خود را ویرایش کنید
  •