SHARE
TWEET

Untitled

a guest Mar 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Bai16.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <math.h>
  7. #include <iomanip>
  8. #include <algorithm>
  9.  
  10. using namespace std;
  11.  
  12.  
  13. struct ToaDo
  14. {
  15.     float x;
  16.     float y;
  17. };
  18. typedef ToaDo TOADO;
  19. typedef TOADO *arr_1D;
  20. typedef TOADO **arr_2D;
  21. template <class T>
  22.  
  23. void Input_Var(char ch, T &k)
  24. {
  25.     cout << ch << " = ";
  26.     cin >> k;
  27. }
  28.  
  29. void Initialize(arr_1D &a)
  30. {
  31.     a = new TOADO;
  32. }
  33.  
  34. void Input(arr_1D *a)
  35. {
  36.     cout << "Nhap vao hoanh do: ";
  37.     cin >> (*a)->x;
  38.     cout << endl;
  39.     cout << "Nhap vao tung do: ";
  40.     cin >> (*a)->y;
  41. }
  42.  
  43. void Output(arr_1D *a)
  44. {
  45.     cout << setw(7) << "(" << setw(7) << (*a)->x << "," << setw(7) << (*a)->y << ")" << setw(7);
  46.     cout << endl;
  47. }
  48.  
  49. void Process()
  50. {
  51.     cout << "Chon yeu cau tu 3 den 14: (Tu 1 den 2 da duoc thuc hien) " << endl;
  52. }
  53.  
  54. void Process_distance(arr_1D a,arr_1D b)
  55. {
  56.     double distance;
  57.     distance = sqrt(pow(a->x - b->x, 2) + pow(a->y - b->y, 2));
  58.     cout << "Khoang cach giua 2 diem la: " << distance << endl;
  59. }
  60.  
  61. void Process_Ox(arr_1D a, arr_1D b)
  62. {
  63.     double distance;
  64.     distance = fabs(a->x - b->x);
  65.     cout << "Khoang cach giua 2 diem theo phuong Ox la: " << distance << endl;
  66. }
  67.  
  68. void Process_Oy(arr_1D a, arr_1D b)
  69. {
  70.     double distance;
  71.     distance = fabs(a->y - b->y);
  72.     cout << "Khoang cach giua 2 diem theo phuong Oy la: " << distance << endl;
  73. }
  74.  
  75. void Process_Symmetry_O(arr_1D a)
  76. {
  77.     a->x = -a->x;
  78.     a->y = -a->y;
  79.     cout << "Diem doi xung qua goc toa do la: " << endl;
  80.     Output(&a);
  81. }
  82.  
  83. void Process_Symmetry_Ox(arr_1D a)
  84. {
  85.     a->y = -a->y;
  86.     cout << "Diem doi xung qua truc hoanh la: " << endl;
  87.     Output(&a);
  88. }
  89.  
  90. void Process_Symmetry_Oy(arr_1D a)
  91. {
  92.     a->x = -a->x;
  93.     cout << "Diem doi xung qua truc tung la: " << endl;
  94.     Output(&a);
  95. }
  96.  
  97. void Process_Bisectrix_1st(arr_1D a)
  98. {
  99.     swap(a->x, a->y);
  100.     cout << "Diem doi xung qua duong phan giac thu nhat (y=x) la: " << endl;
  101.     Output(&a);
  102. }
  103.  
  104. void Process_Bisectrix_2nd(arr_1D a)
  105. {
  106.     swap(a->x,a->y);
  107.     a->x = -a->x;
  108.     a->y = -a->y;
  109.     cout << "Diem doi xung qua duong phan giac thu hai (y=-x) la: " << endl;
  110.     Output(&a);
  111. }
  112.  
  113. void ProcessI(arr_1D a)
  114. {
  115.     if (a->x > 0 && a->y > 0)
  116.         cout << "Diem thuoc phan tu thu I." << endl;
  117.     else
  118.         cout << "Diem khong thuoc phan tu thu I!!!" << endl;
  119. }
  120.  
  121. void ProcessII(arr_1D a)
  122. {
  123.     if (a->x < 0 && a->y > 0)
  124.         cout << "Diem thuoc phan tu thu II." << endl;
  125.     else
  126.         cout << "Diem khong thuoc phan tu thu II!!!" << endl;
  127. }
  128.  
  129. void ProcessIII(arr_1D a)
  130. {
  131.     if (a->x < 0 && a->y < 0)
  132.         cout << "Diem thuoc phan tu thu III." << endl;
  133.     else
  134.         cout << "Diem khong thuoc phan tu thu III!!!" << endl;
  135. }
  136.  
  137. void ProcessIV(arr_1D a)
  138. {
  139.     if (a->x > 0 && a->y < 0)
  140.         cout << "Diem thuoc phan tu thu IV." << endl;
  141.     else
  142.         cout << "Diem khong thuoc phan tu thu IV!!!" << endl;
  143. }
  144.  
  145. int main()
  146. {
  147.     arr_1D a, b;
  148.     int y;
  149.     Initialize(a);
  150.     Initialize(b);
  151.     Input(&a);
  152.     Output(&a);
  153.     Input(&b);
  154.     Output(&b);
  155.     Process();
  156.     Input_Var('y', y);
  157.     switch (y)
  158.     {
  159.     case 3:
  160.     {
  161.         Process_distance(a, b);
  162.         break;
  163.     }
  164.     case 4:
  165.     {
  166.         Process_Ox(a, b);
  167.         break;
  168.     }
  169.     case 5:
  170.     {
  171.         Process_Oy(a, b);
  172.         break;
  173.     }
  174.     case 6:
  175.     {
  176.         Process_Symmetry_O(a);
  177.         Process_Symmetry_O(b);
  178.         break;
  179.     }
  180.     case 7:
  181.     {
  182.         Process_Symmetry_Ox(a);
  183.         Process_Symmetry_Ox(b);
  184.         break;
  185.     }
  186.     case 8:
  187.     {
  188.         Process_Symmetry_Oy(a);
  189.         Process_Symmetry_Oy(b);
  190.         break;
  191.     }
  192.     case 9:
  193.     {
  194.         Process_Bisectrix_1st(a);
  195.         Process_Bisectrix_1st(b);
  196.         break;
  197.     }
  198.     case 10:
  199.     {
  200.         Process_Bisectrix_2nd(a);
  201.         Process_Bisectrix_2nd(b);
  202.         break;
  203.     }
  204.     case 11:
  205.     {
  206.         ProcessI(a);
  207.         ProcessI(b);
  208.         break;
  209.     }
  210.     case 12:
  211.     {
  212.         ProcessII(a);
  213.         ProcessII(b);
  214.         break;
  215.     }
  216.     case 13:
  217.     {
  218.         ProcessIII(a);
  219.         ProcessIII(b);
  220.         break;
  221.     }
  222.     case 14:
  223.     {
  224.         ProcessIV(a);
  225.         ProcessIV(b);
  226.     }
  227.     default:
  228.         break;
  229.     }
  230.     delete[] a;
  231.     return 0;
  232. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top