注册 登录
编程论坛 C++教室

圆面积的程序错误!

lockhawk 发布于 2008-09-20 23:28, 983 次点击
#include "iostream.h"
int main()
{
float r;
float s;
const float pi=3.14F
cout<<"请输入半径:";
cin>>r;
s=pi*r*r;
cout<<"圆的面积是:"<<s<<endl;
return 0;
}
这个程序我怎么看都没错误。怎么一biuld就显示“有一个错误?

我用的是VC6。0
8 回复
#2
thanatus2008-09-20 23:35
#include <iostream>//这句也许不用改,我用的不是vc6.0编译器
int main()
{

using namespace std;//加上这句,否则不认识cout

float r;
float s;
const float pi=3.14F;//漏了分号
cout<<"请输入半径:";
cin>>r;
s=pi*r*r;
cout<<"圆的面积是:"<<s<<endl;
return 0;
}
#3
fmcmfans2008-09-22 09:02
const float pi=3.14F少了个分号
#4
lockhawk2008-09-22 14:57
呵呵~太谢谢了~自己写漏个符号是很难发现的
#5
谌俭2008-10-11 01:53
以后要注意点哦
#6
kevin882008-10-11 08:44
回复 4# lockhawk 的帖子
有错误提示看的啊!
#7
p1s2008-10-11 13:22
编译器的错误提示会是非常好的参考资料。
#8
choco10242008-10-11 16:27
看看错误提示不就知道了。
#9
xmnathan2008-10-12 18:21
到后面也许就因为一个分号  会出现非常奇怪的提示
1