我試圖寫C++一個rutine讀取如下所示的輸入文件,從最後一列決定例行對輸入文件
1 12 13 0 0 1 0 INLE
2 1 12 0 0 1 0 INLE
3 11 2 0 0 1 0 INLE
4 13 11 0 0 1 0 INLE
5 2 8 0 0 2 0 OUTL
6 8 9 0 0 2 0 OUTL
7 9 10 0 0 2 0 OUTL
8 10 3 0 0 2 0 OUTL
9 4 5 0 0 3 0 SYMP
10 5 6 0 0 3 0 SYMP
11 6 7 0 0 3 0 SYMP
12 7 1 0 0 3 0 SYMP
13 14 4 0 0 4 0 WALL
14 16 14 0 0 4 0 WALL
15 15 16 0 0 4 0 WALL
16 3 15 0 0 4 0 WALL
在這種情況下,我必須ASIGN的值第二列和第三列與右側最後一列中指定的條件相符。 喜歡的東西,
read the last column;
if it reads the word INLE
{
asign the values of COLUMN2 and COLUMN3 to the pointer &p_InflowNode[i];
}
if it reads the word OUTL
{
asign the values of COLUMN2 and COLUMN3 to the pointer &p_NonrefNode[i];
}
etc...
所以我的主要問題是,怎樣才能讓我的C++第一次讀的最後一列,然後再決定如何處理第二和第三列的值嗎?
Thaks