Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <vector>
- #include <iterator>
- #include <time.h>
- #include <algorithm>
- using namespace std;
- class Coords
- {
- public:
- vector < pair<double, double> > crd;
- int Sz;
- bool Zpt;
- vector < pair<double, double> > Part1;
- vector < pair<double, double> > Part2;
- vector < pair<double, double> > Part3;
- vector < pair<double, double> > Part4;
- pair <double, double> xy;
- ////////////
- Coords()
- {
- Zpt= false;
- cout << "Введите размер массива координат = "; cin >> Sz;
- srand(time(0)); double dataX, dataY; int dX, dY;
- for (int a=0; a< Sz; a++)
- {
- dX= rand()%100-50; dataX= double(dX)/10.0;
- dY= rand()%100-50; dataY= double(dY)/10.0;
- xy.first= dataX; xy.second= dataY;
- crd.push_back(xy);
- }
- }
- //////////////
- void OutData()
- {
- cout << setw(10) << "Xcoord" << setw(10) << "Ycoord" << endl;
- for (int a=0; a<Sz; a++)
- {
- xy= crd[a];
- cout << setw(10) << xy.first << setw(10) << xy.second << endl;
- }
- }
- /////////////
- void PartName(int i)
- {
- if (i<crd.size())
- {
- xy= crd[i];
- if (xy.first<0 && xy.second<0) Part3.push_back(xy);
- if (xy.first>0 && xy.second>0) Part1.push_back(xy);
- if (xy.first<0 && xy.second>0) Part4.push_back(xy);
- if (xy.first>0 && xy.second<0) Part2.push_back(xy);
- if (xy.first==0 && xy.second==0) Zpt= true;
- return;
- }
- cout << "Количество точек в" << endl;
- cout << "Первой четверти " << Part1.size() << endl;
- cout << "Второй четверти " << Part2.size() << endl;
- cout << "Третьей четверти " << Part3.size() << endl;
- cout << "Четвёртой четверти " << Part4.size() << endl;
- cout << "Точка в центре координат ";
- Zpt ? cout << "присутствует" : cout << "отсутствует";
- cout << endl;
- }
- //////////////
- void SortPart()
- {
- int it= 0;
- while (it<=crd.size())
- {
- PartName(it);
- it++;
- }
- }
- //////////////
- ~Coords()
- {
- }
- ///////////////
- private:
- protected:
- };
- ///////////////////////////////////
- int main(int argc, char **argv)
- {
- // Руссификация сообщений
- system("chcp 1251 > nul");
- SetConsoleTitle(TEXT("ОтветыМейлРу")); //Для совместимости с VS
- Coords c; c.OutData(); c.SortPart();
- cout<<endl; system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment