Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vcl.h>
- #include <iostream>
- #include <windows.h>
- #include <math.h>
- #include <stdio.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int coord[100][2],max[2][2],n,i,j,m;
- cout <<"Введите размерность плоскости (m) и количество точек для плоскости размером mxm через пробел. \n" << endl;
- scanf("%d %d", &m, &n);
- printf("Получившиеся точки: \n");
- srand((unsigned int)time(NULL));
- for ( i=1; i <= n; i++) {
- for ( j=1; j <= 2; j++)
- coord[i][j]= rand() % m;
- printf ("%d ",coord[i][1]);
- printf ("%d",coord[i][2]);
- printf ("\n");
- }
- max[1][1]=0;
- max[1][2]=0;
- max[2][1]=0;
- max[2][2]=0;
- for (i=1; i <= n; i++)
- for (j=1; j <= n; j++){
- if (abs(coord[i][1]-coord[j][1])+abs(coord[i][2]-coord[j][2])> abs(max[1][1]-max[2][1])+abs(max[1][2]-max[2][2])) {
- max[1][1]=coord[i][1];
- max[1][2]=coord[i][2];
- max[2][1]=coord[j][1];
- max[2][2]=coord[j][2];
- }
- }
- cout << "Координаты самых дальних точек \n" << max[1][1] << " " << max[1][2] << "\n" << max[2][1] << " " << max[2][2] << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement