0
我已經設定了一個小程序找到任何數量的 的COS鑽,結果是所有怪 的CMD:結果沒有意義麼?
類型數量0.00
effincisy5
您的COS = 008C129E
按任意鍵繼續。 。 。
代碼:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
float cos67 (float l,float j)
{
int k=0;
float sum=0,i=1;
while (k<=j)
{
sum +=i;
i*=(-l*l/((2*l)*(2*l-1)));
k+=1;
}
return sum;
}
int main(){
float l,j;
cout<<"type the number ";
cin>>l;
cout<<endl<<"effincisy" ;
cin>>j;
cout<<endl;
cos67(l,j);
cout<<"your cos ="<<cos67<<endl;
return 0;
}
爲什麼結果對數的信嗎?
或這是什麼意思?
Typo; 'cout <<「你的cos =」<< cos67 << endl;'需要是'cout <<「你的cos =」<< cos67(l,j)<< endl;'你可以去掉' cos67(l,j);'這是在它自己的路線上。 – NathanOliver
因爲您正在打印函數的地址而不是結果... – Borgleader