[問題] 'std' redeclared as different kind of symbol

看板C_and_CPP作者 (sariel)時間12年前 (2013/12/12 23:21), 編輯推噓0(007)
留言7則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 出現[Error]'(double std(int, double*))'redeclared as different kind of symbol 不知道該如何解決 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) #include<iostream> #include<cmath> using namespace std; double mean(int n,double data[]) { double sum,average,b,sumb,s; for(int i=0;i<n;i++) { sum+=data[i]; } average=sum/n; cout<<" 總平均為:" <<average<<endl; return 0; } double std(int n,double data[]) { double sum,average,b,sumb,s; for(int q=0;q<n;q++) { b=pow(data[q],2); sumb+=b; } s= sqrt((sumb/n-pow(average,2))); cout<<" 標準差為:" <<s<<endl; return 0; } int main (){ int n; double data[1000]; cout<<"請問想輸入幾個數字?"; cin>>n; for(int i=0;i<n;i++) { cout<<"請輸入第"<<i+1<<"個數字:"; cin>>data[i]; } mean(n, &data[0]); std(n, &data[0]); return 0; } 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.126.36.171

12/12 23:22, , 1F
不好意思,我寫的是一個解平均值跟標準差
12/12 23:22, 1F

12/12 23:23, , 2F
平均值的答案有出來,但是標準差的卻卡住了
12/12 23:23, 2F

12/12 23:24, , 3F
在下新手,不好意思
12/12 23:24, 3F

12/12 23:28, , 4F
不要叫std, 改叫 calculate_std 之類的
12/12 23:28, 4F

12/12 23:28, , 5F
std跟內建的撞名了
12/12 23:28, 5F

12/12 23:33, , 6F
有了,非常謝謝您
12/12 23:33, 6F

12/13 23:45, , 7F
看看你code第三行XD
12/13 23:45, 7F
文章代碼(AID): #1IgTI15R (C_and_CPP)