Advertisement
Guest User

Untitled

a guest
Dec 17th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <random>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. struct Trngl
  10. {
  11. int x1;
  12. int y1;
  13. int x2;
  14. int y2;
  15. int x3;
  16. int y3;
  17. }tr[3];
  18.  
  19. struct Part
  20. {
  21. int lx;
  22. int rx;
  23. int uy;
  24. int dy;
  25. }Prt[4];
  26.  
  27. class CoordFlor
  28. {
  29. public:
  30.  
  31. CoordFlor (int *arr)
  32. {
  33. mt19937 gen ((int)time(0));
  34. uniform_int_distribution<int> disty(0,400);
  35. uniform_int_distribution<int> distx(0,300);
  36.  
  37. for (int i=0;i<3;i++)
  38. {
  39. tr[i].x1= distx(gen); tr[i].y1= disty(gen);
  40. tr[i].x2= distx(gen); tr[i].y2= disty(gen);
  41. tr[i].x3= distx(gen); tr[i].y3= disty(gen);
  42. }
  43.  
  44. int crdIt= -1;
  45. for (int i=0;i<4;i++)
  46. {
  47. Prt[i].dy= arr[++crdIt]; Prt[i].uy= arr[++crdIt];
  48. Prt[i].lx= arr[++crdIt]; Prt[i].rx= arr[++crdIt];
  49. }
  50. }
  51. //////////////
  52. void PrintCoord()
  53. {
  54. cout << "Координаты плоскости по четвертям" << endl;
  55.  
  56. for (int i=0; i<4; i++)
  57. {
  58. cout << "Четверть №" << (i+1) << " dy\\uy, lx\\rx ";
  59. cout << "\t" << Prt[i].dy << " , " << Prt[i].uy << " ; ";
  60. cout << "\t" << Prt[i].lx << " , " << Prt[i].rx << endl;
  61. }
  62.  
  63. cout << endl;
  64.  
  65. cout << "Координаты вершин треугольника"<< endl;
  66. for (int i=0; i<3; i++)
  67. {
  68. cout << "Треугольник №" << (i+1) << endl;
  69. cout << "X1= " << tr[i].x1 << " Y1= " << tr[i].y1;
  70. cout << "\t X2= " << tr[i].x2 << " Y2= " << tr[i].y2;
  71. cout << "\t X3= " << tr[i].x3 << " Y3= " << tr[i].y3;
  72. cout << endl;
  73. }
  74.  
  75. }
  76. };
  77.  
  78. int main(int argc, char **argv)
  79. {
  80. system("chcp 1251 > nul"); // Руссификация сообщений
  81. setlocale(LC_ALL, "Russian");
  82.  
  83. int crd[16]= {1,150,1,200,1,150,-200,-1,-1,-150,-200,-1,-1,-150,1,200};
  84.  
  85. CoordFlor cf(crd); cf.PrintCoord();
  86.  
  87. system("pause"); // system("pause > nul");
  88. return 0;
  89. }
  90.  
  91.  
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement