Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bai16.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- #include <algorithm>
- using namespace std;
- struct ToaDo
- {
- float x;
- float y;
- };
- typedef ToaDo TOADO;
- typedef TOADO *arr_1D;
- typedef TOADO **arr_2D;
- template <class T>
- void Input_Var(char ch, T &k)
- {
- cout << ch << " = ";
- cin >> k;
- }
- void Initialize(arr_1D &a)
- {
- a = new TOADO;
- }
- void Input(arr_1D *a)
- {
- cout << "Nhap vao hoanh do: ";
- cin >> (*a)->x;
- cout << endl;
- cout << "Nhap vao tung do: ";
- cin >> (*a)->y;
- }
- void Output(arr_1D *a)
- {
- cout << setw(7) << "(" << setw(7) << (*a)->x << "," << setw(7) << (*a)->y << ")" << setw(7);
- cout << endl;
- }
- void Process()
- {
- cout << "Chon yeu cau tu 3 den 14: (Tu 1 den 2 da duoc thuc hien) " << endl;
- }
- void Process_distance(arr_1D a,arr_1D b)
- {
- double distance;
- distance = sqrt(pow(a->x - b->x, 2) + pow(a->y - b->y, 2));
- cout << "Khoang cach giua 2 diem la: " << distance << endl;
- }
- void Process_Ox(arr_1D a, arr_1D b)
- {
- double distance;
- distance = fabs(a->x - b->x);
- cout << "Khoang cach giua 2 diem theo phuong Ox la: " << distance << endl;
- }
- void Process_Oy(arr_1D a, arr_1D b)
- {
- double distance;
- distance = fabs(a->y - b->y);
- cout << "Khoang cach giua 2 diem theo phuong Oy la: " << distance << endl;
- }
- void Process_Symmetry_O(arr_1D a)
- {
- a->x = -a->x;
- a->y = -a->y;
- cout << "Diem doi xung qua goc toa do la: " << endl;
- Output(&a);
- }
- void Process_Symmetry_Ox(arr_1D a)
- {
- a->y = -a->y;
- cout << "Diem doi xung qua truc hoanh la: " << endl;
- Output(&a);
- }
- void Process_Symmetry_Oy(arr_1D a)
- {
- a->x = -a->x;
- cout << "Diem doi xung qua truc tung la: " << endl;
- Output(&a);
- }
- void Process_Bisectrix_1st(arr_1D a)
- {
- swap(a->x, a->y);
- cout << "Diem doi xung qua duong phan giac thu nhat (y=x) la: " << endl;
- Output(&a);
- }
- void Process_Bisectrix_2nd(arr_1D a)
- {
- swap(a->x,a->y);
- a->x = -a->x;
- a->y = -a->y;
- cout << "Diem doi xung qua duong phan giac thu hai (y=-x) la: " << endl;
- Output(&a);
- }
- void ProcessI(arr_1D a)
- {
- if (a->x > 0 && a->y > 0)
- cout << "Diem thuoc phan tu thu I." << endl;
- else
- cout << "Diem khong thuoc phan tu thu I!!!" << endl;
- }
- void ProcessII(arr_1D a)
- {
- if (a->x < 0 && a->y > 0)
- cout << "Diem thuoc phan tu thu II." << endl;
- else
- cout << "Diem khong thuoc phan tu thu II!!!" << endl;
- }
- void ProcessIII(arr_1D a)
- {
- if (a->x < 0 && a->y < 0)
- cout << "Diem thuoc phan tu thu III." << endl;
- else
- cout << "Diem khong thuoc phan tu thu III!!!" << endl;
- }
- void ProcessIV(arr_1D a)
- {
- if (a->x > 0 && a->y < 0)
- cout << "Diem thuoc phan tu thu IV." << endl;
- else
- cout << "Diem khong thuoc phan tu thu IV!!!" << endl;
- }
- int main()
- {
- arr_1D a, b;
- int y;
- Initialize(a);
- Initialize(b);
- Input(&a);
- Output(&a);
- Input(&b);
- Output(&b);
- Process();
- Input_Var('y', y);
- switch (y)
- {
- case 3:
- {
- Process_distance(a, b);
- break;
- }
- case 4:
- {
- Process_Ox(a, b);
- break;
- }
- case 5:
- {
- Process_Oy(a, b);
- break;
- }
- case 6:
- {
- Process_Symmetry_O(a);
- Process_Symmetry_O(b);
- break;
- }
- case 7:
- {
- Process_Symmetry_Ox(a);
- Process_Symmetry_Ox(b);
- break;
- }
- case 8:
- {
- Process_Symmetry_Oy(a);
- Process_Symmetry_Oy(b);
- break;
- }
- case 9:
- {
- Process_Bisectrix_1st(a);
- Process_Bisectrix_1st(b);
- break;
- }
- case 10:
- {
- Process_Bisectrix_2nd(a);
- Process_Bisectrix_2nd(b);
- break;
- }
- case 11:
- {
- ProcessI(a);
- ProcessI(b);
- break;
- }
- case 12:
- {
- ProcessII(a);
- ProcessII(b);
- break;
- }
- case 13:
- {
- ProcessIII(a);
- ProcessIII(b);
- break;
- }
- case 14:
- {
- ProcessIV(a);
- ProcessIV(b);
- }
- default:
- break;
- }
- delete[] a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement