[問題] 可以幫忙Debug一下嗎?><

看板C_and_CPP (C/C++)作者時間15年前 (2011/05/17 23:57), 編輯推噓4(4027)
留言31則, 10人參與, 最新討論串1/1
#include <iostream> #include <cstdlib> #include <cmath> #include <fstream> #include <iomanip> #include <algorithm> #include <iostream> #include <cstdlib> #include <cmath> #include <numeric> using namespace std; double K_hf=0.43,KaiA=1.3; double A(double S); double S; double part1,part2,part3,part4,part5,part6,part7,part8,part9; //做一個能夠讀Kxy就輸出已知的Kxy值的函式,如 K12表示Ksd,即由 S state形成 D state的速率常數 double Kxy(int x,int y,double A) { static double const k0[4][4] = {{0,0,0,0},{0.21,0,0,0},{0,0,0,0.31}, {0.11,0,0,0}}; //(U,T,D,S) static double const ka[4][4] = {{0,0.479077,0,0.0532308}, {0.0798462,0,0.212923,0},{0,0.1730000,0,-0.319385},{-0.3 ,0,0.505692,0}}; return k0[x][y] + ( ka[x][y]*A )/(K_hf+A) ; } double A(double S) { return std::max(0.0, KaiA-2*S ); } part1=-Kxy(0,1,A)-Kxy(1,0,A)-Kxy(1,2,A); part2=Kxy(2,1,A)-Kxy(0,1,A); part3=-(0.479077*(-2*K_hf)/pow((K_hf+KaiA-2*S),2))*S-Kxy(0,1,A(S)); part4=Kxy(1,2,A(S)); part5= -Kxy(2,1,A(S))-Kxy(2,3,A(S)); part6=-(0.505692*(-2*K_hf)/pow((K_hf+KaiA-2*S),2))*S-Kxy(3,2,A(S)); part7=-Kxy(0,3,A(S)); part8=Kxy(2,3,A(S)); part9=-(-0.133077*(-2*K_hf)/pow((K_hf+KaiA-2*S),2))*S- (0.505692*(-2*K_hf)/pow((K_hf+KaiA-2*S),2))*S-Kxy(0,3,A(S)) -Kxy(3,0,A(S))-Kxy(3,2,A(S)); int main() { cin>>S; cout<<part1<<"\t"<<part2<<"\t"<<part3<<"\t"<<part4<<"\t"<<part5<<"\t"<<part6<< "\t"<<part7<<"\t"<<part8<<"\t"<<part9<<endl; system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.31.5

05/18 00:00, , 1F
請給錯誤訊息
05/18 00:00, 1F
錯誤訊息 C:\Users\Ben\Desktop\拜託盡量順吧.cpp:28: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:28: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:29: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:29: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:30: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:30: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:31: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:31: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:32: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:32: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:33: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:33: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:34: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:34: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:35: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:35: error: expected `,' or `;' before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:36: error: expected constructor, destructor, or type conversion before '=' token C:\Users\Ben\Desktop\拜託盡量順吧.cpp:36: error: expected `,' or `;' before '=' token ※ 編輯: skylion 來自: 140.115.31.5 (05/18 00:06)

05/18 00:07, , 2F
次方要用pow(x,2),不是x^2
05/18 00:07, 2F

05/18 00:08, , 3F
你的程式讓我很不順@@"
05/18 00:08, 3F

05/18 00:08, , 4F
很幽默的檔名
05/18 00:08, 4F

05/18 00:10, , 5F
還有你的S宣告在哪...
05/18 00:10, 5F

05/18 00:11, , 6F
2*S寫成2S...光是這個錯誤就知道你不認真...
05/18 00:11, 6F

05/18 00:12, , 7F
END
05/18 00:12, 7F

05/18 00:14, , 8F
最離譜的就是endl寫成end1...英文跟數字搞不清楚
05/18 00:14, 8F

05/18 00:20, , 9F
Orz 抱歉 請問大大 這樣對嗎 pow((K_hf+KaiA-2*S),2)
05/18 00:20, 9F

05/18 00:21, , 10F
如果就我想描述的式子 那個平方項是這樣改嗎?><
05/18 00:21, 10F

05/18 00:24, , 11F
見議 你先排版一次
05/18 00:24, 11F

05/18 00:25, , 12F
第二 A是function 你的輸入參數?
05/18 00:25, 12F
※ 編輯: skylion 來自: 140.115.31.5 (05/18 00:32)

05/18 00:39, , 13F
............
05/18 00:39, 13F

05/18 00:39, , 14F
重新排版了一下Orz 還是不知為何好像括號數量有錯的樣子Or
05/18 00:39, 14F

05/18 00:41, , 15F
S 沒宣告的關係吧 造成編譯器誤判符號
05/18 00:41, 15F

05/18 00:41, , 16F
A和宣告S 還有part1~9放到main內
05/18 00:41, 16F

05/18 00:42, , 17F
我講的改完就差不多了
05/18 00:42, 17F

05/18 00:42, , 18F
我的S是要經由Cin輸入進去計算 宣告是說 double S嗎?
05/18 00:42, 18F

05/18 00:42, , 19F
看到它S了 宣告在外面....
05/18 00:42, 19F

05/18 00:42, , 20F
那不是已經有宣告了嗎?><
05/18 00:42, 20F

05/18 00:43, , 21F
你寫得不好 別人看不懂也不意外..= =
05/18 00:43, 21F

05/18 00:44, , 22F
把我說的另外兩個處理好就差不多了吧 (應該
05/18 00:44, 22F

05/18 00:45, , 23F
大大你說的A是什麼意思?Orz
05/18 00:45, 23F

05/18 00:47, , 24F
感謝大大!可以跑了 可以從中學習點教訓嗎?QQ part1擺裡面
05/18 00:47, 24F

05/18 00:48, , 25F
和擺外面為啥會不同呢?QQ
05/18 00:48, 25F

05/18 00:55, , 26F
就 寫程式時 仔細+認真 寫完一部份就先編譯一次吧
05/18 00:55, 26F

05/18 00:55, , 27F
至於為啥不同 你去問你的老師吧..= =
05/18 00:55, 27F

05/18 10:34, , 28F
= =為什麼標題檔有三個是重複的,而且檔名用中文
05/18 10:34, 28F

05/18 18:00, , 29F
其實是{}的問題....
05/18 18:00, 29F

05/19 16:40, , 30F
~"~你真的幫他debug喔
05/19 16:40, 30F

05/19 18:27, , 31F
給原PO:看到錯誤訊息是第幾行 就往哪邊找...
05/19 18:27, 31F
文章代碼(AID): #1Dqfhjbv (C_and_CPP)
文章代碼(AID): #1Dqfhjbv (C_and_CPP)