一个简单的C++程序困扰我好久啊

来源:百度知道 编辑:UC知道 时间:2024/07/05 22:56:10
#include<iostream>
using namespace std;
const flaot PI=3.1416;
void main()
{
int i,r,wild,chang,zhchang;
cout<<"please chose the tyse/n"<<"yuan:0,zheng:1,chang:2"<<endl;
cin>>i;
switch(i)
{
case 0:cout<<"please input the r"<<endl;
cin>>r;
cout<<endl;
cout<<"yuan de mian ji wei"<<endl;
cout<<PI*r*r<<endl;
break;
case 1:cout<<"please input the wild and chang"<<endl;
cin>>wild>>chang;
cout<<endl;
cout<<"chang fang xing de mian ji shi:"<<endl;
cout<<chang*wild<<endl;
break;
case 2:cout<<"please input de zhchang"<<endl;
cin>>zhchang;
cout<<endl;
cout<<"zheng fang xing de mian ji shi:"<<endl;
cout<

第三行改为
const float PI=3.1416;

楼上的,
#include<iostream>
using namespace std;
才是标准C++

问题楼上的已经找出来了,还有一点就是程序里,你要求第一排正方形输入1,长方形输入2,但是在SWITCH语句中好象搞反了吧^^
<<当然这个不是编译错误的原因= =|||

#include<iostream>
using namespace std;
const flaot PI=3.1416;

试着把 using namespace std; 去掉
flaot写错了,应该是float 最好改为double
把#include<iostream>改为#include<iostream.h>
PS:我用的是VC++