.


:




:

































 

 

 

 


Visual Studio 2008




(Solution Explorer) (. 13.1) (Add). New Item ( ) Exiting Item ( ). , , . 13.2.

13.3. #include , , .

13.1

 

 

13.2

 

13.3

 

.

 

13.1

 

. , . , . .

 

:

- .

- :

o :

o :

- .

 

.

 

, . cartesian , polar .

 

.

 

. :

1. double len(cartesian a, cartesian b) .

2. double len(polar a, polar b) .

3. double len(cartesian a, polar b) , , .

 

4. double len(polar a, cartesian b) , , .

5. polar cartesian_to_polar(cartesian x) .

6. cartesian polar_to_cartesian(polar x) .

 

.

, , : PRG-Lab13.cpp , ; points.cpp ; points.h , .

 

points.h

 

// points.h: .

//

#ifndef POINTS_H

#define POINTS_H

 

//

//

struct cartesian{

double x, y;

};

 

//

struct polar{

double r, pi;

};

 

//

double len(polar a, polar b);

double len(cartesian a, cartesian b);

double len(cartesian a, polar b);

double len(polar a, cartesian b);

 

polar cartesian_to_polar(cartesian x);

cartesian polar_to_cartesian(polar x);

#endif

 

points.cpp

 

. . ( ). , , , , , .

 

// points.cpp:

//

 

#include "stdafx.h"

#include "points.h"

#include <math.h>

 

 

double len(polar a, polar b)

{

return sqrt(pow(a.r, 2) + pow(b.r, 2) - 2*a.r*b.r*cos(a.pi - b.pi));

}

 

double len(cartesian a, cartesian b)

{

return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));

}

 

double len(cartesian a, polar b)

{

cartesian c;

 

c = polar_to_cartesian(b);

 

return len(a, c);

}

 

double len(polar a, cartesian b)

{

return len(b, a);

}

 

polar cartesian_to_polar(cartesian x)

{

polar y;

 

y.r = sqrt(pow(x.x, 2) + pow(x.x, 2));

 

if (y.r == 0)

y.pi = 0;

else

y.pi = asin(x.y/y.r);

 

return y;

}

 

cartesian polar_to_cartesian(polar x)

{

cartesian y;

 

y.x = x.r*cos(x.pi);

y.y = x.r*sin(x.pi);

 

return y;

 

}

 

PRG-Lab13.cpp

 

// PRG-Lab13.cpp: ,

//

 

#include "stdafx.h"

#include <iostream>

#include "points.h"

 

using namespace std;

 

void main(int argc, char* argv[])

{

setlocale(LC_ALL, "Russian");

 

const double PI = 3.14159;

 

cartesian a = {3, 0},

b = {1, 1};

 

polar c = {1.41, PI/4},

d = {3.1, 0.95};

 

//

//

// -

cout << len(a, b) << endl;

// -

cout << len(c, d) << endl;

// -

cout << len(a, d) << endl;

// -

cout << len(c, b) << endl;

}

 

 

, .

1. ?

2. ?

3. ?

4. ?

5. ?

6. , ?

1. .

2. (.h .cpp).

3. .

4. 5, .

5. .

6. .

7. .

8. 5, .

9. .

10. .

1. , . :

1.1. (, , ).

1.2. : , , .

1.3. : , ( ).

2. , . :

2.1. int.

2.2. long.

2.3. float.

2.4. double.

3. , . :

3.1. int N.

3.2. float N.

3.3. double N.

4. , . :

4.1. int.

4.2. int.

4.3. float.

4.4. double.

5. , . :

5.1. (, , ).

5.2. : , , .

5.3. : , ( ).

6. , . :

6.1. (, , ).

6.2. : , , .

6.3. : , ( ).

7. , . :

7.1. int.

7.2. long.

7.3. float.

7.4. double.

8. , . :

8.1. (, , ).

8.2. : , , .

8.3. : , .

9. , . :

9.1. (, , ).

9.2. : , , .

9.3. : , .

10. , . :

10.1. int N.

10.2. float N.

10.3. double N.

11. , . :

11.1. (, , ).

11.2. : , , .

11.3. : , ( ).

12. , . :

12.1. ( x, y).

12.2. float.

12.3. double.

13. , . :

13.1. (, , ).

13.2. : , , .

13.3. : , .

14. , . :

14.1. int N.

14.2. float N.

14.3. double N.

15. , (, 24 ). :

15.1. (, , ).

15.2. : , , .

15.3. : , .

16. , . :

16.1. int.

16.2. int.

16.3. float.

16.4. float.

16.5. double.

17. , . :

17.1. (, , ).

17.2. : , , .

17.3. : , ( ).

18. , n- x. :

18.1. : x n int.

18.2. : x n float.

18.3. : x float, n int.

19. , . :

19.1. int N.

19.2. float N.

19.3. double N.

20. , . :

20.1. (, , ).

20.2. : , , .

20.3. : , .

21. , . :

21.1. int.

21.2. int.

21.3. float.

21.4. double.

22. , ( , 1 1- ). :

22.1. (, , ).

22.2. : , , .

22.3. : , ( ).

23. , . :

23.1. int N.

23.2. float N.

23.3. double N.

24. , . :

24.1. int.

24.2. int.

24.3. float.

24.4. double.

25. , . :

25.1. (, , ).

25.2. : , , .

25.3. : , ( ).

 

1. .

2. .

3. .

4. .

5. .

6. .

7. .

 

 





:


: 2017-01-21; !; : 384 |


:

:

, .
==> ...

941 - | 875 -


© 2015-2024 lektsii.org - -

: 0.063 .