C++怎么使用lg 和ln?

我这么写的 为啥显示log10 和ln错误?#include "stdafx.h"
#include<iostream>
#include<cmath>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int n;
float x,y;
for(n=90;n<=100;n++)
{
cout<<n;
x=log10(n);
cout<<x;
y=ln(n);
cout<<y;
}
return 0;
}

第1个回答  2013-03-22
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[])
{
int n;
double x,y;
for(n=90;n<=100;n++)
{
cout<<n;
x=log10((long double)n); // log10 的函数表示
cout << x << endl;
y=log((long double)n); // ln 的函数表示
cout << y << endl;
}
return 0;
}本回答被提问者采纳
第2个回答  2013-03-22
参数类型不对.另外,有ln函数吗?是log吧.追问

参数类型为啥不对?应该改成什么?log函数表示什么?

相似回答