| ²é¿´: 730 | »Ø¸´: 6 | |||
| µ±Ç°Ö÷ÌâÒѾ´æµµ¡£ | |||
zhanglei22Òø³æ (СÓÐÃûÆø)
|
[½»Á÷]
¡¾ÇóÖú¡¿ºÃÐÄÈ˰ïÎÒ¿´¿´Õâ¸ö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 ] |
» ²ÂÄãϲ»¶
352·Ö-085602-Ò»Ö¾Ô¸985
ÒѾÓÐ3È˻ظ´
291Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
330·ÖÇóµ÷¼Á
ÒѾÓÐ4È˻ظ´
309Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
0856Çóµ÷¼Á
ÒѾÓÐ13È˻ظ´
0703»¯Ñ§
ÒѾÓÐ11È˻ظ´
329Çóµ÷¼Á
ÒѾÓÐ7È˻ظ´
321Çóµ÷¼Á
ÒѾÓÐ8È˻ظ´
0856²ÄÁÏ»¯¹¤µ÷¼Á ×Ü·Ö330
ÒѾÓÐ12È˻ظ´
070300»¯Ñ§354Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
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="< } ºÙºÙ£¬ÊDZàÒë´íÎó°É£¬ ÊÇÄãµÄ±ÊÎó°¡£¬°ïÄãÓúìÉ«±ê³öÀ´ÁË ±à³ÌµÄʱºòÒ»¶¨ÒªÏ¸ÐÄŶ£¡ |
2Â¥2009-09-23 10:36:16
zhanglei22
Òø³æ (СÓÐÃûÆø)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 355.6
- Ìû×Ó: 134
- ÔÚÏß: 28·ÖÖÓ
- ³æºÅ: 831417
- ×¢²á: 2009-08-20
3Â¥2009-09-23 16:45:22
hxz
ľ³æ (ÕýʽдÊÖ)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 2105
- Ìû×Ó: 370
- ÔÚÏß: 16.7Сʱ
- ³æºÅ: 176464
- ×¢²á: 2006-02-05
- ÐÔ±ð: GG
- רҵ: ÓÀ¶¯»ú
¡ï
Сľ³æ(½ð±Ò+0.5):¸ø¸öºì°ü£¬Ð»Ð»»ØÌû½»Á÷
Сľ³æ(½ð±Ò+0.5):¸ø¸öºì°ü£¬Ð»Ð»»ØÌû½»Á÷
|
ûд¿½±´¸´Öƺ¯Êý ½á¹¹¸³Öµ²»ÄÜÓÃ= lzµÄ´¿c·ç¸ñ ‡å |
4Â¥2009-09-23 16:51:37
hxz
ľ³æ (ÕýʽдÊÖ)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 2105
- Ìû×Ó: 370
- ÔÚÏß: 16.7Сʱ
- ³æºÅ: 176464
- ×¢²á: 2006-02-05
- ÐÔ±ð: GG
- רҵ: ÓÀ¶¯»ú
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














»Ø¸´´ËÂ¥
