±±¾©Ê¯ÓÍ»¯¹¤Ñ§Ôº2026ÄêÑо¿ÉúÕÐÉú½ÓÊÕµ÷¼Á¹«¸æ
²é¿´: 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="<         cout<<" degrees\n";
}

[ Last edited by nono2009 on 2009-9-30 at 00:00 ]
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

yeyunxiao

Ìú¸Ëľ³æ (СÓÐÃûÆø)

¡ï ¡ï ¡ï ¡ï
Сľ³æ(½ð±Ò+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="<         cout<<" degrees\n";
}

ºÙºÙ£¬ÊDZàÒë´íÎó°É£¬

ÊÇÄãµÄ±ÊÎó°¡£¬°ïÄãÓúìÉ«±ê³öÀ´ÁË

±à³ÌµÄʱºòÒ»¶¨ÒªÏ¸ÐÄŶ£¡
2Â¥2009-09-23 10:36:16
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

zhanglei22

Òø³æ (СÓÐÃûÆø)

лл

ÎÒÊÇÂÛ̳ÐÂÈË ÇÒ ÐÂÊÖѧvc£¡

  ¸ÐлºÃÐÄÈ˰ïæ!

  ÎÒÔÚ¿´ c++ primer plus Õâ±¾Ê飬 ÓÃvc++ 6.0ÔËÐУ¬ ËûÀïÃæµÃ Õâ¸öÓï¾ä
    using namespace std:   ±ØÐëɾÁË ²ÅÄÜÔÚvc++ 6.0 ÔËÐС£ÎÒÓеãÒ»Öª°ë½â¡£

  
  »¹ÓÐÎÒÓÐcµÃ »ù´¡ £¬Ç°ÃæµÄ»ù´¡ һɨ¶ø¹ý£¬ÖصãÏë¿´ºóÃæ ¶ÔÏó°¡  ÀàʲôµÄ£¬
ÕâÖÖ·½·¨¿ÉÐаɣ¿
3Â¥2009-09-23 16:45:22
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

hxz

ľ³æ (ÕýʽдÊÖ)

¡ï
Сľ³æ(½ð±Ò+0.5):¸ø¸öºì°ü£¬Ð»Ð»»ØÌû½»Á÷
ûд¿½±´¸´Öƺ¯Êý ½á¹¹¸³Öµ²»ÄÜÓÃ=
lzµÄ´¿c·ç¸ñ ‡å
4Â¥2009-09-23 16:51:37
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

hxz

ľ³æ (ÕýʽдÊÖ)

ÒýÓûØÌû:
Originally posted by zhanglei22 at 2009-9-23 16:45:
ÎÒÊÇÂÛ̳ÐÂÈË ÇÒ ÐÂÊÖѧvc£¡

  ¸ÐлºÃÐÄÈ˰ïæ!

  ÎÒÔÚ¿´ c++ primer plus Õâ±¾Ê飬 ÓÃvc++ 6.0ÔËÐУ¬ ËûÀïÃæµÃ Õâ¸öÓï¾ä
    using namespace std:   ±ØÐëɾÁË ²ÅÄÜÔÚvc++ 6.0 ÔËÐС£ÎÒÓеãÒ»Öª°ë½â¡£

...

ÒòΪc++ primer plusÓõÄÊÇiso c++±ê×¼, vc6²»ÍêÈ«¼æÈÝ
ѧc++×îºÃ²»ÒªÓÃvc6
5Â¥2009-09-23 16:53:38
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
6Â¥2009-09-23 23:55:53
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

green84

½ð³æ (ÕýʽдÊÖ)

ŬÁ¦Ñ§Ï°~

°ïÄãдÁ˸öÀà

¡ï ¡ï ¡ï ¡ï
Сľ³æ(½ð±Ò+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;
}

//ËäÈ»±ÈÄãдµÄ¸´ÔÓµã,µ«ÊǽøÐÐÁËÀà·â×°,ÀàµÄÀ©Õ¹ÐÔ¸üºÃ.
//^_^
//Ëæ±ãдд,Çë´ó¼ÒÖ¸½Ì¹þ
------------------------------------------ The group of Organic Synthesis£º31626069.Welcome everybody to join us!
7Â¥2009-09-29 23:23:22
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ zhanglei22 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] 352·Ö-085602-Ò»Ö¾Ô¸985 +3 º£Äɰٴ¨Ly 2026-03-29 3/150 2026-03-29 07:15 by 380984326
[¿¼ÑÐ] Ò»Ö¾Ô¸±±¾©Àí¹¤´óѧ±¾¿Æ211²ÄÁϹ¤³Ì294Çóµ÷¼Á +6 mikasaµÄΧ½í 2026-03-28 6/300 2026-03-29 01:32 by fmesaito
[¿¼ÑÐ] µ÷¼Á310 +7 ÎÂÈáµÄÍí°² 2026-03-25 8/400 2026-03-29 01:09 by ÎÒÊÇС¿µ
[¿¼ÑÐ] ²ÄÁÏѧ˶333Çóµ÷¼Á +10 ±±µÀÏï 2026-03-24 10/500 2026-03-28 23:06 by Î޼ʵIJÝÔ­
[¿¼ÑÐ] 0703»¯Ñ§µ÷¼Á£¬Çóµ¼Ê¦ÊÕ +9 ÌìÌìºÃÔËÀ´Éϰ¶° 2026-03-24 10/500 2026-03-28 22:17 by chemzp
[¿¼ÑÐ] һ־Ը̫ԭÀí¹¤°²È«¹¤³Ì300·Ö£¬Çóµ÷¼Á +5 0857Çóµ÷¼Á. 2026-03-24 6/300 2026-03-28 22:04 by zhq0425
[¿¼ÑÐ] 283Çóµ÷¼Á +3 A child 2026-03-28 3/150 2026-03-28 15:41 by ms629
[¿¼ÑÐ] 0703»¯Ñ§Çóµ÷¼Á +9 ÄÌÓͲÝÝ®. 2026-03-22 10/500 2026-03-28 13:30 by ÌÆãå¶ù
[¿¼ÑÐ] 266·Ö£¬Çó²ÄÁÏÒ±½ðÄÜÔ´»¯¹¤µÈµ÷¼Á +7 ÍÛºôºßºôºß 2026-03-27 9/450 2026-03-28 12:22 by zllcz
[¿¼ÑÐ] ²ÄÁÏÇóµ÷¼ÁÒ»Ö¾Ô¸¹þ¹¤´ó324 +7 ãÆÐñ¶« 2026-03-28 9/450 2026-03-28 08:51 by Xu de nuo
[¿¼ÑÐ] Çóµ÷¼Á +8 ÕÅzz111 2026-03-27 9/450 2026-03-28 03:41 by fmesaito
[¿¼ÑÐ] 352·Ö »¯¹¤Óë²ÄÁÏ +5 º£Äɰٴ¨Ly 2026-03-27 5/250 2026-03-28 03:39 by fmesaito
[¿¼ÑÐ] 275Çóµ÷¼Á +10 jjjjjjjjjjl 2026-03-27 10/500 2026-03-27 23:47 by barnett0632
[¿¼ÑÐ] ²ÄÁÏÓ뻯¹¤085600£¬×Ü·Ö304£¬±¾¿ÆÓÐÁ½Æªsci²ÎÓ룬Çóµ÷¼Á +10 ÐÒÔ˵Ľ´½´ 2026-03-22 12/600 2026-03-27 16:08 by muchong357
[¿¼ÑÐ] Çóµ÷¼Á +3 Áõ¿Â@ 2026-03-24 4/200 2026-03-27 11:28 by shangxh
[¿¼ÑÐ] 329Çóµ÷¼Á +7 Å¥¶÷Ñ© 2026-03-25 7/350 2026-03-27 04:28 by wxiongid
[¿¼ÑÐ] 343Çóµ÷¼Á +4 ÔùÎÒÒ»±¾Êé 2026-03-23 4/200 2026-03-27 00:40 by wxiongid
[¿¼ÑÐ] 341Çóµ÷¼Á +7 ÇàÄûÃÊ1 2026-03-26 7/350 2026-03-27 00:19 by wxiongid
[¿¼ÑÐ] Çóµ÷¼Á +8 Auroracx 2026-03-22 8/400 2026-03-26 19:55 by ²»³Ôô~µÄ؈
[¿¼ÑÐ] Ò»Ö¾Ô¸¼ªÁÖ´óѧ²ÄÁÏÓ뻯¹¤303·ÖÇóµ÷¼Á +4 Ϊѧ666 2026-03-24 4/200 2026-03-25 11:27 by BruceLiu320
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û