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