| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 493 人关注过本帖
标题:[求助]遇见错误了请过来看一下啊,谢谢
只看楼主 加入收藏
nan123
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-8-1
收藏
 问题点数:0 回复次数:5 
[求助]遇见错误了请过来看一下啊,谢谢

一个小程序编译时遇见错误,分析不出来,谢谢您啊

#include<iostream>
using namespace std;
const float PI=3.1416;
void main()
{
int iTpye;
float radius,a,b,area;
cout<<"what is the graphic types?(one circle,two rectangle,three square):";
cin>>iType;
switch(iType)
{
case 1:
cout<<"circle radius:";
cin>>radius;
area=PI*radius*radius;
cout<<"area is:"<<area<<endl;
break;
case 2:
cout<<"rectangle long is:";
cin>>a;
cout<<"rectangle width:";
cin>>b;
area=a*b;
cout<<"the area of rectangle is:"<<area<<endl;
break;
case 3:
cout<<"square side:";
cin>>a;
area=a*a;
cout<<"the area of square is:"<<area<<endl;
break;
default:
cout<<"it is a nonlicet value!"<<endl;
}
}

--------------------Configuration: division - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/division.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

division.exe - 2 error(s), 0 warning(s)

搜索更多相关主题的帖子: 遇见 
2007-01-04 19:37
soc01
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-6
收藏
得分:0 
int iTpye;
float radius,a,b,area;
cout<<"what is the graphic types?(one circle,two rectangle,three square):";
cin>>iType;
打错了吧!
还有个警告
truncation from 'const double' to 'const float'
最好改成double型的。

2007-01-04 21:48
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
#include<iostream>
using namespace std;
const double PI=3.1416; //float------double
void main()
{
int iType; //int iTpye;?????
float radius,a,b,area;
cout<<"what is the graphic types?(one circle,two rectangle,three square):";
cin>>iType;
switch(iType)
{
case 1:
cout<<"circle radius:";
cin>>radius;
area=PI*radius*radius;
cout<<"area is:"<<area<<endl;
break;
case 2:
cout<<"rectangle long is:";
cin>>a;
cout<<"rectangle width:";
cin>>b;
area=a*b;
cout<<"the area of rectangle is:"<<area<<endl;
break;
case 3:
cout<<"square side:";
cin>>a;
area=a*a;
cout<<"the area of square is:"<<area<<endl;
break;
default:
cout<<"it is a nonlicet value!"<<endl;
}
}

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-01-04 21:59
nan123
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-8-1
收藏
得分:0 
谢谢soc01,yuyunliuhen两位大哥啊
我现在就修改运行看看 
2007-01-05 17:54
nan123
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-8-1
收藏
得分:0 
成.
iType是粗心打错了

为什么换成double就行呢
2007-01-05 18:07
Arcticanimal
Rank: 3Rank: 3
等 级:论坛游民
威 望:7
帖 子:341
专家分:20
注 册:2007-3-17
收藏
得分:0 

float 参与计算时会先转换为 double 类型


try new catch
2007-03-18 13:58
快速回复:[求助]遇见错误了请过来看一下啊,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056526 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved