Guest User

Untitled

a guest
May 22nd, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <vector>
  6. #include <iterator>
  7. #include <time.h>
  8. #include <algorithm>
  9.  
  10. using namespace std;
  11.  
  12. class Coords
  13. {
  14. public:
  15. vector < pair<double, double> > crd;
  16. int Sz;
  17. bool Zpt;
  18.  
  19. vector < pair<double, double> > Part1;
  20. vector < pair<double, double> > Part2;
  21. vector < pair<double, double> > Part3;
  22. vector < pair<double, double> > Part4;
  23.  
  24. pair <double, double> xy;
  25.  
  26. ////////////
  27. Coords()
  28. {
  29. Zpt= false;
  30. cout << "Введите размер массива координат = "; cin >> Sz;
  31.  
  32. srand(time(0)); double dataX, dataY; int dX, dY;
  33. for (int a=0; a< Sz; a++)
  34. {
  35. dX= rand()%100-50; dataX= double(dX)/10.0;
  36. dY= rand()%100-50; dataY= double(dY)/10.0;
  37. xy.first= dataX; xy.second= dataY;
  38. crd.push_back(xy);
  39. }
  40. }
  41. //////////////
  42. void OutData()
  43. {
  44. cout << setw(10) << "Xcoord" << setw(10) << "Ycoord" << endl;
  45. for (int a=0; a<Sz; a++)
  46. {
  47. xy= crd[a];
  48. cout << setw(10) << xy.first << setw(10) << xy.second << endl;
  49. }
  50. }
  51. /////////////
  52.  
  53. void PartName(int i)
  54. {
  55. if (i<crd.size())
  56. {
  57. xy= crd[i];
  58. if (xy.first<0 && xy.second<0) Part3.push_back(xy);
  59. if (xy.first>0 && xy.second>0) Part1.push_back(xy);
  60. if (xy.first<0 && xy.second>0) Part4.push_back(xy);
  61. if (xy.first>0 && xy.second<0) Part2.push_back(xy);
  62. if (xy.first==0 && xy.second==0) Zpt= true;
  63. return;
  64. }
  65.  
  66. cout << "Количество точек в" << endl;
  67. cout << "Первой четверти " << Part1.size() << endl;
  68. cout << "Второй четверти " << Part2.size() << endl;
  69. cout << "Третьей четверти " << Part3.size() << endl;
  70. cout << "Четвёртой четверти " << Part4.size() << endl;
  71. cout << "Точка в центре координат ";
  72. Zpt ? cout << "присутствует" : cout << "отсутствует";
  73. cout << endl;
  74. }
  75. //////////////
  76. void SortPart()
  77. {
  78. int it= 0;
  79. while (it<=crd.size())
  80. {
  81. PartName(it);
  82. it++;
  83. }
  84. }
  85. //////////////
  86. ~Coords()
  87. {
  88.  
  89. }
  90. ///////////////
  91. private:
  92. protected:
  93. };
  94.  
  95. ///////////////////////////////////
  96. int main(int argc, char **argv)
  97. {
  98. // Руссификация сообщений
  99.  
  100. system("chcp 1251 > nul");
  101. SetConsoleTitle(TEXT("ОтветыМейлРу")); //Для совместимости с VS
  102.  
  103. Coords c; c.OutData(); c.SortPart();
  104. cout<<endl; system("pause");
  105. return 0;
  106. }
  107.  
  108.  
Advertisement
Add Comment
Please, Sign In to add comment