这是我编写的程序:
#include "stdafx.h"
#include "math.h"
int main ()
{
int phi;
float c;
scanf_s("%d",&phi);
c=(pow(sin(phi)*cos(phi),-2))-(pow(tan(phi),2)+pow(tan(phi),-2));
if (c==2)
{
printf("C is 2,Don't Worry \n");
}
else
{
printf("Be Careful,C is not 2,How is this possible ?! \n");
}
}
问题是 Visual Studio 无法识别 sin、cos、tan 和 pow。 我究竟做错了什么 ? (如您所见,语言是 C!)
最佳答案
尽管您没有指出错误消息,但最可能的答案是您需要明确告诉编译器您希望将代码视为 C 源文件而不是 C++ 源文件。 Visual Studio 没有“按原样”用于 C 控制台应用程序的项目模板,但您可以手动添加源文件。只需确保其扩展名为 .c
而不是 .cpp
。
关于c - Visual Studio 2012 中的 #include <math.h>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26743107/