你好,我想問關於二維數組中的比較問題。 我有以下2d數組與每個行中的雙參數。 我想比較第5行(即:期間0)與第5行(即:期間1) 我想比較 比較將逐行作爲1d數組我需要兩個1 d數組來比較彼此。Java二維數組比較
示例;
週期0(行0)與期間1(行0,ROW1,ROW2,ROW3,ROW4)
週期0行1對週期1(行0,ROW1,ROW2,ROW3,ROW4)
週期0行2比周期1(行0,ROW1,ROW2,ROW3,ROW4)
週期0行3比周期1(行0,ROW1,ROW2,ROW3,ROW4)
週期0第4行vs第1期(第0行,第1行,第2行,第3行,第4行)
然後
時期1行0對時間段2(行0,ROW1,ROW2,ROW3,ROW4)
時期1行1對週期2(行0,ROW1,ROW2,ROW3,ROW4 )
時期1行2比期間2(行0,ROW1,ROW2,ROW3,ROW4)
時期1行3比期間2(行0,ROW1,ROW2,ROW3,ROW4)
期間1行4與期間2(行0,行1,行2,行3,行4)
然後
時期2行0對週期3(行0,ROW1,ROW2,ROW3,ROW4)
時期2行1對週期3(行0,ROW1,ROW2, ROW3,ROW4)
時期2行2比周期3(行0,ROW1,ROW2,ROW3,ROW4)
期間2行3比周期3(行0,ROW1,ROW2,ROW3,ROW4)
時期2行4對週期3(行0,ROW1,ROW2,ROW3,ROW4)
我的目標是獲得期0的第一行,然後將其轉換爲一維數組,然後採取的第一行Period1然後將其轉換爲1d陣列等。
2d陣列如下;
雙[] [] = myDistributions新雙[] [] {
row0 {0.15250886479593964,0.2610516793197853,0.11441768814194446,0.1265241345428162,0.3454976331995246},
row1 {0.14389124837314887,0.10513281153155449,0.1833462741873425,0.36788054102686596,0.1997491248810186},
Period0 row2 {0.1111207312911868,0.17499901413730568,0.2914581757577288,0.20433331657432438,0.2180887622394655},
row3 {0.0948730457966342,0.19288720600625753,0.19471332499886804,0.18018001280247228,0.3373464103957629},
row4 {0.18877271931210932,0.26521449714587747,0.13230019262559328,0.27631809895720494,0.13739449195931552},
row0 {0.1274517393962726,0.10526928843184565,0.35751329613481436,0.12240396832200726,0.2873617077151316},
row1 {0.3016290729137225,0.09902028076323677,0.17515717333485062,0.35620664945852193,0.06798682352968743},
Period1 row2 {0.0948730457966342,0.19288720600625753,0.19471332499886804,0.18018001280247228,0.3373464103957629},
row3 {0.18877271931210932,0.26521449714587747,0.13230019262559328,0.27631809895720494,0.13739449195931552},
row4 {0.17804585265772793,0.25651982583759037,0.3860867129515085,0.09453797159458521,0.08480963695844175},
row0 {0.2311120677942418,0.07901250493611567,0.15795189397863776,0.24546018732208122,0.28646334596884354},
row1 {0.08823944830766299,0.26313933789756516,0.10406419933285384,0.3365866979847223,0.20797031647719286},
Period2 row2 {0.1274517393962726,0.10526928843184565,0.35751329613481436,0.12240396832200726,0.2873617077151316},
row3 {0.3016290729137225,0.09902028076323677,0.17515717333485062,0.35620664945852193,0.06798682352968743},
row4 {0.11962680738039468,0.1590225091909952,0.24009305610431117,0.11189649648370673,0.36936113084052996},
row0 {0.17804585265772793,0.25651982583759037,0.3860867129515085,0.09453797159458521,0.08480963695844175},
row1 {0.08823944830766299,0.26313933789756516,0.10406419933285384,0.3365866979847223,0.20797031647719286},
Period3 row2 {0.1274517393962726,0.10526928843184565,0.35751329613481436,0.12240396832200726,0.2873617077151316},
row3 {0.0948730457966342,0.19288720600625753,0.19471332499886804,0.18018001280247228,0.3373464103957629},
row4 {0.3962773409768214,0.12002724792315751,0.15722439889764284,0.11854502459707339,0.20792598760527947}};
我不太明白你想如何比較每一行。 –
你試圖達到什麼樣的比較(等於,大於,小於,在範圍內,全部)? – DevilsHnd
感謝您的回覆Jacob G.,我認爲前5行是我的期間0然後第二個5行是我的期間1,然後第三個5行是我的期間2,並保持5行是我的期間3我有一個函數獲取2 1d數組作爲輸入。所以,首先我的函數輸入將是(週期0行0)和(週期1行0) – mstfky