Trang 1 / 2 12 LastLast
Hiển thị kết quả từ 1 đến 10 / 19
  1. #1
    Tham gia
    22-10-2009
    Bài viết
    13
    Like
    0
    Thanked 0 Times in 0 Posts

    Câu hỏi, cần giúp đỡ Cấu trúc dữ liệu và giải thuật

    help me.!!.
    huhu, có ai giúp e với. bọn e fải làm bài tập về Cài đặt giải thuật duyệt cây (trước ,sau,giữa). bọn em chỉ fải làm duyệt sau thôi(làm cả 3 thì càng tốt ạ). Pác nào giúp em với k thì e chết mất. e xyn cảm ơn rất rất nhiều !!
    Yêu cầu: -ý tưởng giải thuật,ý tưởng chương trình.
    -Chạy được chương trình.
    Quote Quote

  2. #2
    Tham gia
    20-03-2007
    Bài viết
    46
    Like
    0
    Thanked 0 Times in 0 Posts
    Đại khái như sau

    Duyệt giữa
    Code:
    procedure attemp(u:node);
    begin
    attemp(u.left);
    //Process u node
    attemp(u.right);
    end;
    Duyệt trước
    Code:
    procedure attemp(u:node);
    begin
    //Process u node
    attemp(u.left);
    attemp(u.right);
    end;
    Duyệt sau
    Code:
    procedure attemp(u:node);
    begin
    attemp(u.left);
    attemp(u.right);
    //Process u node
    end;

  3. #3
    Tham gia
    19-10-2009
    Bài viết
    73
    Like
    0
    Thanked 0 Times in 0 Posts
    Cấu trúc này có vẻ giống Binary Search Tree nhỉ? :-?

  4. #4
    Tham gia
    10-12-2009
    Bài viết
    1
    Like
    0
    Thanked 0 Times in 0 Posts

    bải tập pascal

    các bạn ơi. trả lời cho mình bài pascal này với, bài toán như sau:hãy sử dụng UNIT MATRAN để nhận vào hai ma trận, rồi tính tổng, tích hai ma trận đó. chuyển vị hai ma trận vào đầu tiên. các bạn gửi vào địa chỉ này cho mình nhé:congkhanhhck@gmail.com, thank các bạn nha

  5. #5
    Tham gia
    22-10-2009
    Bài viết
    13
    Like
    0
    Thanked 0 Times in 0 Posts
    cảm ơn các pác nhé!!! nhưg mà không hỉu sao nó lại ko chạy hả pạn ơi??? toàn báo lỗi ở ngay dòng đầu tiên thui

  6. #6
    Tham gia
    02-11-2007
    Bài viết
    9
    Like
    0
    Thanked 0 Times in 0 Posts
    Các bạn ơi, ai có giải thuật tính giá trị trung bình của cây nhị phân bằng phương pháp đệ qui không post cho mình với, hoặc bạn nào có ý tưởng giải thuật nào không xin chỉ giúp. thanks

  7. #7
    Tham gia
    28-12-2009
    Bài viết
    1
    Like
    0
    Thanked 0 Times in 0 Posts
    cac anh oi em dang hoc cau truc du lieu va giai thuat pascal em dang can cac dang bai tap co loi giai va de thi de em hoc va chuan bi kiem tra.anh nao co cho em xin voi!

  8. #8
    Tham gia
    29-05-2004
    Location
    Hue
    Bài viết
    149
    Like
    0
    Thanked 0 Times in 0 Posts
    Gởi Bạn congkhanhhck, nếu đây là bài tập, Bạn phải tự làm. Dưới đây tôi chỉ giúp gợi ý cách làm bằng thư viện
    theo phương pháp hướng đối tượng và sử dụng con trỏ cấp phát bộ nhớ động, Bạn nào cần đều có thể sử dụng thư viện này.
    Chúc các Bạn thành công.

    file TYPEOBJ như sau:

    Unit Typeobj;
    {Nguoi viet: Duong Quang Minh, SV 87X3 DHBK Da Nang}
    Interface
    {$R-}
    Type
    typ = real{double};
    onereal = array[1..1] of typ;
    onerealptr= ^onereal;
    tst = string[50];
    tfile = file of typ;
    Implementation
    {$R+}
    END.{ of Unit }


    file thư viện vec tơ ma trận như sau:

    Unit VeMaobj;
    {Nguoi viet: Duong Quang Minh, SV 87X3 DHBK Da Nang}
    {$N+,R-,f-}
    Interface
    Uses typeobj,printer;

    Type
    Realvector = object
    Maxvectorsize,
    Vsize :word;
    Vecptr :onerealptr;
    vectoropstatus:boolean;
    Constructor Init(maxelem:word {in});
    Destructor Done;
    Function currensize:word;
    Procedure Store(index:word {in}; x:typ{in});
    Procedure Recall(index:word {in};Var x:typ{out});
    Procedure Fill(fillvalue:typ {in};numelem:word{in});
    Procedure Addscalar(scalar:typ{in});
    Procedure Multscalar(scalar:typ{in});
    Procedure AddVector(vectB:realvector{in});
    Function Multvector(vectB:realvector{in}):typ;
    End;
    Realmatrix=object
    Nrow,Ncol,
    Rows,Cols : word;
    Matptr : onerealptr;
    Deteminant : typ;
    Matopstatus: boolean;
    Function Loc(row,{in} col:word {in}):word;
    Constructor Init(numrow,{in} numcol:word {in});
    Destructor Done;
    Procedure Querysize(var numrow,{out} numcol:word {out});
    Procedure Store(Row,{in} col:word {in}; x:typ{in});
    Procedure Recall(Row,{in} col:word {in};Var x:typ{out});
    Procedure Fill(fillvalue:typ {in};rowcount{in},colcount:word{in});
    Procedure Addscalar(scalar:typ{in});
    Procedure Multscalar(scalar:typ{in});

    {
    Cac phuong thuc duoi day cac ban tu giai quyet nhe

    Procedure MultVector(invect:realvector {in};Var outvect:realvector{out}); {nhan voi vec to}
    Procedure VectorMult(invect:realvector{in};Var outvect:realvector{out}); {nhan vec to voi ma tran}
    Procedure MultMatrix(inmat:realmatrix{in};Var outmat:realmatrix{out}); {nhan voi ma tran inmat}
    Procedure Movematrix(Var matb:realmatrix{out}); {chuyen ma tran}
    Procedure Readmatrix(numrows{in},numcols{in}:word); {doc ma tran}
    Procedure Writematrix(numrows{in},numcols{in}:word); {ghi ma tran}
    Procedure Matrix_1;{DK Rows=Cols} {nghich dao}
    Procedure Matrix_T(var outmat:realmatrix); {chuyen vi}
    procedure Addmatrix(inmat:realmatrix;var outmat:realmatrix); {cong ma tran}
    procedure ChinhLK(ro:typ;mat1,t,mat2:realmatrix); {cac phuong thuc con lai dung de giai bai toan ket cau}
    procedure ChuyentrucK(t,mat:realmatrix);
    procedure StoreAll(inmat:realmatrix);
    procedure ChuyentrucF(t,f:realmatrix);
    Procedure GiaiHe(mttt:realmatrix{in};
    Var mtas:realmatrix{out});
    }
    End;


    Implementation
    Uses crt;
    Constructor Realvector.Init(maxelem:word {in});
    Begin
    maxvectorsize:=maxelem;
    vsize:=0;
    Getmem(vecptr,maxelem*sizeof(typ));
    vectoropstatus:=true;
    End;
    Destructor realvector.done;
    var temp : typ;
    Begin
    temp:=vecptr^[1];
    freemem(vecptr,maxvectorsize*sizeof(typ));
    vecptr:=Nil;
    maxvectorsize:=0;
    vsize:=0;
    vectoropstatus:=true;
    End;
    function realvector.currensize:word;
    Begin
    vectoropstatus:=true;
    currensize:=vsize;
    End;
    Procedure realvector.store(index:word;{in} x:typ {in});
    Begin
    If index>maxvectorsize then begin
    vectoropstatus:=false;
    Exit;
    End;
    vecptr^[index]:=x;
    If index>vsize then vsize:=index;
    vectoropstatus:=true;
    End;
    Procedure realvector.recall(index:word{in};Var x:typ{out});
    Begin
    If index>vsize then begin
    vectoropstatus:=false;
    x:=0;
    Exit;
    end;
    x:=vecptr^[index];
    vectoropstatus:=true;
    End;
    Procedure realvector.Fill(fillvalue:typ {in};numelem:word{in});
    Var i:word;
    Begin
    If numelem>maxvectorsize then
    numelem:=maxvectorsize;
    vsize:=numelem;
    for i:=1 to numelem do
    vecptr^[i]:=fillvalue;
    vectoropstatus:=true;
    End;
    Procedure realvector.addscalar(scalar:typ{in});
    Var i:word;
    Begin
    for i:=1 to vsize do
    vecptr^[i]:=vecptr^[i]+scalar;
    vectoropstatus:=true;
    End;
    Procedure realvector.Multscalar(scalar:typ{in});
    Var i:word;
    Begin
    for i:=1 to vsize do
    vecptr^[i]:=vecptr^[i]*scalar;
    vectoropstatus:=true;
    End;
    Procedure realvector.addvector(vectB:realvector{in});
    Var i:word;
    Begin
    if vsize<>vectb.vsize then begin
    vectoropstatus:=false;
    Exit;
    end;
    for i:=1 to vsize do
    vecptr^[i]:=vecptr^[i]+vectB.vecptr^[i];
    vectoropstatus:=true;
    End;
    Function realvector.multvector(vectB:realvector{in}):typ;
    Var i:word;
    sum:typ;
    Begin
    If vsize<>vectb.vsize then begin
    vectoropstatus:=false;
    multvector:=0;
    exit;
    end;
    sum:=0;
    for i:=1 to vsize do
    sum:=sum+vecptr^[i]*vectB.vecptr^[i];
    vectoropstatus:=true;
    Multvector:=sum;
    End;
    Function realmatrix.Loc(row{in},col{in}:word):word;
    Begin
    Loc:=(row-1)*Ncol+col;
    End;
    Constructor realmatrix.Init(numrow{in},numcol{in}:word);
    Begin
    Ncol:=numcol;
    Nrow:=numrow;
    rows:=0;
    cols:=0;
    Getmem(matptr,numcol*numrow*sizeof(typ));
    matopstatus:=true;
    End;
    Destructor realmatrix.done;
    var temp : typ;
    Begin
    temp:=matptr^[loc(1,1)];
    freemem(matptr,nrow*ncol*sizeof(typ));
    matptr:=nil;
    rows:=0;
    cols:=0;
    nrow:=0;
    ncol:=0;
    temp:=0;
    matopstatus:=true;
    End;
    Procedure realmatrix.querysize(Var numrow{out},numcol{out}:word);
    Begin
    numrow:=rows;
    numcol:=cols;
    matopstatus:=true;
    End;
    Procedure realmatrix.store(row{in},col{in}:word;x:typ{in});
    Begin
    If (row>nrow) or (col>ncol) then begin
    matopstatus:=false;
    exit;
    end;
    If row>rows then
    rows:=row;
    If col>cols then
    cols:=col;
    matptr^[loc(row,col)]:=x;
    matopstatus:=true;
    End;
    Procedure realmatrix.recall(row{in},col{in}:word;Var x:typ{out});
    var gia:typ;
    Begin
    If (row>rows) or (col>cols) then begin
    matopstatus:=false;
    x:=0;
    exit;
    end;
    x:=matptr^[loc(row,col)];
    if ((row=nrow) and (col=ncol)) then gia:=matptr^[loc(1,1)];
    matopstatus:=true;
    End;
    Procedure realmatrix.fill(fillvalue:typ{in};rowcount{in},col count{in}:word);
    Var i,j:word;
    Begin
    IF rowcount>nrow then
    rowcount:=nrow;
    If colcount>ncol then
    colcount:=ncol;
    rows:=rowcount;
    cols:=colcount;
    for i:=1 to rowcount do
    for j:=1 to colcount do
    matptr^[loc(i,j)]:=fillvalue;
    matopstatus:=true;
    End;
    Procedure realmatrix.addscalar(scalar:typ{in});
    Var i,j,k:word;
    Begin
    for i:=1 to rows do
    for j:=1 to cols do begin
    k:=loc(i,j);
    matptr^[k]:=matptr^[k]+scalar;
    end;
    matopstatus:=true;
    End;
    Procedure realmatrix.multscalar(scalar:typ{in});
    Var i,j,k:word;
    Begin
    for i:=1 to rows do
    for j:=1 to cols do begin
    k:=loc(i,j);
    matptr^[k]:=matptr^[k]*scalar;
    end;
    matopstatus:=true;
    End;

    {$R+,F+}
    END.{ of Unit }

  9. #9
    Tham gia
    28-11-2009
    Bài viết
    3
    Like
    0
    Thanked 0 Times in 0 Posts

    ban co the viet giup minh doan code nay khong

    cho một mảng a={12,32,45,6,5,767,9}--->a={6,12,32,767,45,9,5}
    hãy sắp xếp sao cho số chẵn tăng dần trứoc và số lẽ giảm dần sau.
    nếu bạn nào có thể chuyển tất cả số chẵn về đầu mảng và sô lẻ về cuối mảng thì cũng được rồi,
    phần còn lại để mình. ví dụ như:
    mảng a sau khi sắp xếp a={12,32,6,45,5,767,9}
    bạn nào có thể viết được thì post len giúp mình nha!

    [=========> Bổ sung bài viết <=========]

    số điện thoại của mình là:01223432477 hoặc 01674630203
    email: 8264@donga.edu.vn
    mong sớm nhận được câu trả lời từ các bạn!!
    Được sửa bởi tanphi12 lúc 09:50 ngày 03-03-2010 Reason: Bổ sung bài viết

  10. #10
    Tham gia
    29-05-2004
    Location
    Hue
    Bài viết
    149
    Like
    0
    Thanked 0 Times in 0 Posts
    Bạn nên chứa chúng vào 2 mảng, 1 mảng chẵn, 1 lẻ. Sau đó sắp xếp các mảng theo ý muốn. Rồi ghép chúng lại với nhau là xong.
    Chúc làm được.

Trang 1 / 2 12 LastLast

Bookmarks

Quy định

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể sửa bài viết của mình
  •