主题:[讨论]C++求救
原代码是
#include<math.h>
int main()
{
float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c);
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%7.2f, b=%7.2f, c=%7.2f, s=%7.2f\n",a,b,c,s);
printf("area=%7.2f\n",area);
return 0;
}
错误是
Compiling...
1111.cpp
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(6) : error C2065: 'scanf' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(7) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(8) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(9) : error C2065: 'printf' : undeclared identifier
执行 cl.exe 时出错.
111.exe - 1 error(s), 0 warning(s)
请问问题出现在哪里啊,我修改过好多次都是这样,麻烦帮我解答一下,谢谢!!
#include<math.h>
int main()
{
float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c);
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%7.2f, b=%7.2f, c=%7.2f, s=%7.2f\n",a,b,c,s);
printf("area=%7.2f\n",area);
return 0;
}
错误是
Compiling...
1111.cpp
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(6) : error C2065: 'scanf' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(7) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(8) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\111\1111.cpp(9) : error C2065: 'printf' : undeclared identifier
执行 cl.exe 时出错.
111.exe - 1 error(s), 0 warning(s)
请问问题出现在哪里啊,我修改过好多次都是这样,麻烦帮我解答一下,谢谢!!