| 查看: 643 | 回复: 6 | |||
| 当前主题已经存档。 | |||
[交流]
【求助】好心人帮我看看这个c++! 谢谢了
|
|||
|
这个程序在vc++ 6.0 怎么运行不了啊 ? 求助!问题在哪里这么改啊 ?谢谢了 #include #include struct polar { double distance; double angle; }; struct rect { double x; double y; }; polar rect_to_polar(rect xypos); void show_polar(polar dapos); int main() { rect rplace; polar pplace; cout<<"Enter the x and y values:"; while(cin>>rplace.x>>rplace.y) { pplace=rect_to_polar(rplace); show_polar(pplace); cout<<"Next two numbers(q to quit):"; } cout<<"Done.\n"; return 0; } polar rect_to_polar(rent xypos) { polar answer; answer.distance=sqrt(xypos.x*xypos.x+xypos.y*xypos.y); answer.angle=atan2(xypos.y,xypos.x); return answer; } void show_polar(pelar dapos) { const double Rad_to_deg=57.29577951; cout<<"distance="<< dapos.distance; cout<<", angle="< } [ Last edited by nono2009 on 2009-9-30 at 00:00 ] |
» 猜你喜欢
三甲基碘化亚砜的氧化反应
已经有4人回复
请问下大家为什么这个铃木偶联几乎不反应呢
已经有5人回复
请问有评职称,把科研教学业绩算分排序的高校吗
已经有5人回复
孩子确诊有中度注意力缺陷
已经有12人回复
2025冷门绝学什么时候出结果
已经有3人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
AI论文写作工具:是科研加速器还是学术作弊器?
已经有3人回复
论文投稿,期刊推荐
已经有4人回复
硕士和导师闹得不愉快
已经有13人回复
yeyunxiao
铁杆木虫 (小有名气)
- 应助: 0 (幼儿园)
- 金币: 6096.1
- 帖子: 106
- 在线: 12.4小时
- 虫号: 588929
- 注册: 2008-08-29
- 性别: GG
- 专业: 计算机软件
★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
wangen994(金币+3,VIP+0):辛苦了,谢谢你对程序软件版的支持 9-23 12:13
小木虫(金币+0.5):给个红包,谢谢回帖交流
wangen994(金币+3,VIP+0):辛苦了,谢谢你对程序软件版的支持 9-23 12:13
|
#include #include struct polar { double distance; double angle; }; struct rect { double x; double y; }; polar rect_to_polar(rect xypos); void show_polar(polar dapos); int main() { rect rplace; polar pplace; cout<<"Enter the x and y values:"; while(cin>>rplace.x>>rplace.y) { pplace=rect_to_polar(rplace); show_polar(pplace); cout<<"Next two numbers(q to quit):"; } cout<<"Done.\n"; return 0; } polar rect_to_polar(rect xypos) { polar answer; answer.distance=sqrt(xypos.x*xypos.x+xypos.y*xypos.y); answer.angle=atan2(xypos.y,xypos.x); return answer; } void show_polar(polar dapos) { const double Rad_to_deg=57.29577951; cout<<"distance="<< dapos.distance; cout<<", angle="< } 嘿嘿,是编译错误吧, 是你的笔误啊,帮你用红色标出来了 编程的时候一定要细心哦! |
2楼2009-09-23 10:36:16
3楼2009-09-23 16:45:22
4楼2009-09-23 16:51:37
5楼2009-09-23 16:53:38
![]() ![]() |
6楼2009-09-23 23:55:53
green84
金虫 (正式写手)
努力学习~
- 应助: 0 (幼儿园)
- 贵宾: 0.7
- 金币: 1025.5
- 帖子: 661
- 在线: 2.6小时
- 虫号: 215562
- 注册: 2006-03-11
- 专业: 化学学科
帮你写了个类
★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
nono2009(金币+3,VIP+0):谢谢热心帮助。欢迎常来交流。 9-30 00:02
小木虫(金币+0.5):给个红包,谢谢回帖交流
nono2009(金币+3,VIP+0):谢谢热心帮助。欢迎常来交流。 9-30 00:02
|
//Crect.h #pragma once class Crect { public: Crect(void); ~Crect(void); bool SetVal(void); double GetX(void) const; double GetY(void) const; private: double m_x; double m_y; }; //Crect.cpp #include using namespace std; #include "Crect.h" Crect::Crect(void):m_x(0.0),m_y(0.0) { } Crect::~Crect(void) { } bool Crect::SetVal() { cout << "Please input the x value: "; cin >> m_x; cout << "Please input the y value: "; cin >> m_y; return true; } double Crect::GetX() const { return m_x; } double Crect::GetY() const { return m_y; } //polar.h #pragma once #include "Crect.h" class CPolar { public: CPolar(void); ~CPolar(void); void SetValFromRect(const Crect& xypos); void Show(void); private: double m_distance; double m_angle; }; //Polar.cpp #include #include using namespace std; #include "Polar.h" CPolar::CPolar(void):m_distance(0.0),m_angle(0.0) { } CPolar::~CPolar(void) { } void CPolar::SetValFromRect(const Crect& xypos) { m_distance = sqrt(xypos.GetX() * xypos.GetX() + xypos.GetY() * xypos.GetY()); m_angle = atan2(xypos.GetY(),xypos.GetX()); } void CPolar::Show() { const double RadToDeg = 57.29577951; cout << "distance = " << m_distance << " angle = " << m_angle * RadToDeg << " degress" << endl; } //main.cpp #include using namespace std; #include "Polar.h" int main() { Crect rect1; CPolar polar1; while(rect1.SetVal()) { polar1.SetValFromRect(rect1); polar1.Show(); } system("Pause"); return 0; } //虽然比你写的复杂点,但是进行了类封装,类的扩展性更好. //^_^ //随便写写,请大家指教哈 ![]() |

7楼2009-09-29 23:23:22














回复此楼

