结果没有意义
what does the result do not make sense?
我已经编程了一个小程序以查找任何数字的cosbur结果都是奇怪的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;
}
为什么结果在数字上有字母?
或它是什么意思?
this:
cout<<"your cos ="<<cos67<<endl;
正在获取功能的地址并显示它。您需要函数返回的值:
cout<<"your cos ="<< cos67(l,j) <<endl;
您正在打印函数的地址,而不是返回值。使用:
cout<<"your cos ="<< cos67(l, j) <<endl;
而不是。
相关文章:
- 在C++中,使用带有 std::optional 参数的函数<T>来表示可选参数是否有意义?
- API 返回智能指针的 std::optional 以明确指定指针可能为 null 是否有意义?
- 从头开始为应用程序创建 docker 映像是否有意义?
- 在c++中,如果首先禁止默认构造,那么禁止复制构造有意义吗
- 为什么我在这个模板上有随机结果?
- sizeof(函数)有意义吗?
- 二进制模式 + 格式化文本操作或文本模式 + 二进制数据操作 - 有意义吗?
- 插入向量时,使用lambda的返回而不是函数的返回是否有意义?
- 在 C++17 中使用 const std::string& 参数有意义吗?
- 基础类模板参数的有意义名称
- 内联这个函数,确实有意义
- 将 final 关键字添加到没有基类(未派生)的类中的虚函数是否有意义
- 为什么会有这个结果
- 左移负整数为零是否有意义?
- 是否有一个上下文表达式`a.b :: c`有意义
- 是否有一些有意义的统计数据来证明保持有符号整数算术溢出未定义是合理的
- 将可选与reference_wrapper相结合是否有意义?
- 函数返回rvalue参考是否有意义
- 将 [[noreturn]] 添加到主函数是否有意义
- 存储三角函数调用的结果是否有意义