線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:723
推到 Plurk!
推到 Facebook!

路徑資料記憶體不足

尚未結案
liyanzi
一般會員


發表:51
回覆:45
積分:19
註冊:2005-01-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-10 12:11:28 IP:203.68.xxx.xxx 未訂閱
請問各位大大,我現正在寫最短路徑的程式    想要增加幾條路,但卻會出現以下的error     這是記憶體不足的關係? 我增加路徑的資料如下
            for ( int i = 0; i < 10; i++ )
                delete_road[ i ] = new Save_roadname ;
        head = new DList ;//先將其設為NULL
        find_head = new DList ;
        for ( int i = 0; i < 10; i++ )
                temp_road[ i ] = new DList ;
        all_num = 0 ;
        DList *pointer, *temp[10] ;
        for ( int i = 0; i < 10; i++ )
                temp[ i ] = new DList ;            head -> number = 1 ;
        head -> roadname = "成功路" ;
        ComboBox1 -> Items -> Add( head -> roadname ) ;
        head -> road = temp[ 0 ] ;  // 成功 -> 自由
        head -> road_numeral = 35 ;
        head -> an_road = NULL ;  // 無
        head -> an_road_numeral = 0 ;            temp[ 0 ] -> number = 2 ;
        temp[ 0 ] -> roadname = "自由路" ;
        ComboBox1 -> Items -> Add( temp[ 0 ] -> roadname ) ;
        temp[ 0 ] -> road = temp[ 1 ] ;  // 自由 -> 博愛
        temp[ 0 ] -> road_numeral = 45 ;
        temp[ 0 ] -> an_road = temp[ 2 ] ;  // 自由 -> 中正
        temp[ 0 ] -> an_road_numeral = 30 ;            temp[ 1 ] -> number = 3 ;
        temp[ 1 ] -> roadname = "博愛路" ;
        ComboBox1 -> Items -> Add( temp[ 1 ] -> roadname ) ;
        temp[ 1 ] -> road = temp[ 3 ] ;  // 博愛 -> 仁愛
        temp[ 1 ] -> road_numeral = 25 ;
        temp[ 1 ] -> an_road = NULL ;  // 無
        temp[ 1 ] -> an_road_numeral = 0 ;            temp[ 2 ] -> number = 4 ;
        temp[ 2 ] -> roadname = "中正路" ;
        ComboBox1 -> Items -> Add( temp[ 2 ] -> roadname ) ;
        temp[ 2 ] -> road = temp[ 3 ];  // 中正 -> 仁愛
        temp[ 2 ] -> road_numeral = 45 ;
        temp[ 2 ] -> an_road = temp[ 4 ];  // 中正 -> 中山
        temp[ 2 ] -> an_road_numeral = 130 ;            temp[ 3 ] -> number = 5 ;
        temp[ 3 ] -> roadname = "仁愛路" ;
        ComboBox1 -> Items -> Add( temp[ 3 ] -> roadname ) ;
        temp[ 3 ] -> road = temp[ 4 ] ;  // 仁愛 -> 中山
        temp[ 3 ] -> road_numeral = 100 ;
        temp[ 3 ] -> an_road = temp[6] ;  // 仁愛->安和
        temp[ 3 ] -> an_road_numeral = 70 ;            temp[ 4 ] -> number = 6 ;
        temp[ 4 ] -> roadname = "中山路" ;
        ComboBox1 -> Items -> Add( temp[ 4 ] -> roadname ) ;
        temp[ 4 ] -> road = temp[ 5 ] ;  // 中山 -> 北安
        temp[ 4 ] -> road_numeral = 50 ;
        temp[ 4 ] -> an_road = NULL ;  // 無
        temp[ 4 ] -> an_road_numeral = 0 ;            temp[ 5 ] -> number = 7;
        temp[ 5 ] -> roadname = "北安路" ;
        ComboBox1 -> Items -> Add( temp[ 5 ] -> roadname ) ;
        temp[ 5 ] -> road = temp[6];  // 北安->安和
        temp[ 5 ] -> road_numeral = 120;
        temp[ 5 ] -> an_road = temp[7] ;  //北安->北門
        temp[ 5 ] -> an_road_numeral = 60;            temp[ 6 ] -> number = 8;
        temp[ 6 ] -> roadname = "安和路" ;
        ComboBox1 -> Items -> Add( temp[ 6 ] -> roadname ) ;
        temp[ 6 ] -> road = temp[7] ;  // 安和->北門
        temp[ 6 ] -> road_numeral = 75 ;
        temp[ 6 ] -> an_road = temp[8];  // 安和->青年
        temp[ 6 ] -> an_road_numeral = 85 ;            temp[ 7 ] -> number = 9;
        temp[ 7 ] -> roadname = "北門路" ;
        ComboBox1 -> Items -> Add( temp[ 7 ] -> roadname ) ;
        temp[ 7 ] -> road = temp[8] ;  // 北門->青年
        temp[ 7 ] -> road_numeral = 30 ;
        temp[ 7 ] -> an_road = NULL ;  // 無
        temp[ 7 ] -> an_road_numeral = 0 ;            temp[ 8 ] -> number = 10;
        temp[ 8 ] -> roadname = "青年路" ;
        ComboBox1 -> Items -> Add( temp[ 8 ] -> roadname ) ;
        temp[ 8 ] -> road = NULL ;  // 無
        temp[ 8 ] -> road_numeral = 0 ;
        temp[ 8 ] -> an_road = NULL ;  // 無
        temp[ 8 ] -> an_road_numeral = 0 ;
windblown
中階會員


發表:0
回覆:117
積分:98
註冊:2003-11-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-08-11 10:13:24 IP:61.229.xxx.xxx 未訂閱
這個錯誤訊息是 "存取不該取用的記憶體位址" 可能是你在陣列的使用上超出範圍,不過因為程式碼資料不足,無法更進一步判斷
系統時間:2024-05-18 6:34:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!