超简单的C语言代码帮忙看看错误

来源:百度知道 编辑:UC知道 时间:2024/05/17 17:35:20
#include "iostream.h"
int main()
{
float r;
float 1;
const float pi=3.1415926F;
cout <<"请输入半径:";
cin >>r;
1-2*pi*r;
cout <<"这个圆的周长为" <<1 <<endl;
return 0;
}
它报错为:
Compiling...
main.cpp
D:\mai\main.cpp(5) : warning C4091: '' : ignored on left of 'float' when no variable is declared
D:\mai\main.cpp(5) : error C2143: syntax error : missing ';' before 'constant'
D:\mai\main.cpp(9) : warning C4552: '-' : operator has no effect; expected operator with side-effect
执行 cl.exe 时出错.
第1天学~请教哈

float 1 错误,float 是用来声明变量的,1是常量。
1-2*pi*r得出的值得赋给一个变量。
你是不是想这么写

float r;
float l;//这是L的小写,不是1
....
l=2*pi*r;
cout<<"这个圆的周长为"<<l<<endl;
....

可能是笔误吧,把l写成1了

你肯定是把数字1看成小写字母l了
应该是float l;
l=2*pi*r;

1-2*pi*r这个公式等于哪个变量?
cout <<"这个圆的周长为" <<1 <<endl;
输出的时候也输出错了

这个,这个问题也太。。。