Tài liệu Bài tập lập trình - code thuật toán prim

Thảo luận trong 'Kế Toán - Kiểm Toán' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    167
    Điểm thành tích:
    0
    Xu:
    0Xu
    program Prim_Algorithm;{chuong trinh nay cai dat bang mang}
    uses dos,crt;
    const max=150;fname='D:PascalFilePrim.txt';
    type
    filename=string[12];
    var
    TrongSo: array[1 max,1 max] of integer;{ma tran trong so cua do thi}
    DinhKe: array[1 max] of integer;{ma tran luu dinh ke}
    CanhKe: array[1 max] of integer;{}
    n, DodaiCayKhung: integer;{so dinh cua do thi}
    i,j: integer;
    ch: char;
    h,m,s, hund:word;

    {----------------------------------------------------------------------------}
    procedure PrintMatrix;
    Begin
    (*In ma tran ra *)
    Writeln('-------------------------------------------------------');
    Writeln('Ma tran trong so, Khong co canh noi thi trong so = MaxInt');
    for i:=1 to n do
    Begin
    For j:=1 to n do
    if TrongSo[i,j]=Maxint then write(' 0',' ')
    else write(TrongSo[i,j]:5,' ');
    Writeln;
    End;
    Writeln('-------------------------------------------------------');
    End;

    {----------------------------------------------------------------------------}
    procedure ReadInputFile;
    var
    i,j: integer;
    f: text;
    begin
    assign(f,fname);
    reset(f);
    readln(f,n);
    for i:=1 to n do
    begin
    for j:=1 to n do
    begin
    read(f,TrongSo[i,j]);
    if TrongSo[i,j]=0 then TrongSo[i,j]:=MaxInt;
    end;
     

    Các file đính kèm:

Đang tải...