[問題] 雙層迴圈之問題
看板C_and_CPP (C/C++)作者filexchang (LTE student researcher)時間11年前 (2014/09/16 10:18)推噓4(4推 0噓 10→)留言14則, 5人參與討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
cmath time.h
問題(Question):
編譯錯誤
餵入的資料(Input):
agent[j].x MD[i].x agent[j].y MD[i].y (用normal distribution產生出的xy座標值)
預期的正確結果(Expected Output):
預期算出任兩點在平面上的距離
錯誤結果(Wrong Output):
[Error] name lookup of 'j'changed for ISO 'for' scoping [-fpermissive]
程式碼(Code):(請善用置底文網頁, 記得排版)
for(int i=0;i<Total_MD-countMD;i++)
{
for(int j=0;i<Total_agent;j++) //用agent的MD
double d = (agent[j].x - MD[i].x)* (agent[i].x - ((/*sqare this*/d =
MD[i].x + agent[j].y - MD[i].y) * d));
double d =(agent[j].x -MD[i].x);
*(agent[j].x-((/*sqare this*/d = MD[i].x + agent[j].y - MD[i].y) * d));
補充說明(Supplement):
這是一個模擬通訊論文的程式,距離上次寫這種類似的模擬程式大約有八年了
因此對程式有些生疏
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.248.162.154
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1410833895.A.788.html
※ 編輯: filexchang (60.248.162.154), 09/16/2014 10:19:14
推
09/16 10:20, , 1F
09/16 10:20, 1F
→
09/16 10:20, , 2F
09/16 10:20, 2F
※ 編輯: filexchang (60.248.162.154), 09/16/2014 10:50:02
→
09/16 10:52, , 3F
09/16 10:52, 3F
→
09/16 10:53, , 4F
09/16 10:53, 4F
推
09/16 11:24, , 5F
09/16 11:24, 5F
→
09/16 11:25, , 6F
09/16 11:25, 6F
→
09/16 11:27, , 7F
09/16 11:27, 7F
→
09/16 11:32, , 8F
09/16 11:32, 8F
我試著把code放到網路上http://codepad.org/loHPHimB請大家幫我看看,感謝!
※ 編輯: filexchang (60.248.162.154), 09/16/2014 12:27:29
→
09/16 17:16, , 9F
09/16 17:16, 9F
→
09/16 17:33, , 10F
09/16 17:33, 10F
推
09/16 17:46, , 11F
09/16 17:46, 11F
推
09/16 17:53, , 12F
09/16 17:53, 12F
→
09/16 17:53, , 13F
09/16 17:53, 13F
→
09/16 18:36, , 14F
09/16 18:36, 14F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章