Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class vector{
- public:
- float x, y;
- void input() {
- cin >> this->x >> this->y;
- }
- float len() {
- return sqrt(this->x*this->x + this->y*this->y);
- }
- vector operator+(vector tmp) {
- float x = this->x + tmp.x;
- float y = this->y + tmp.y;
- if (x >= 7)
- x -= 7;
- if (y >= 7)
- y -= 7;
- vector tmp_;
- tmp_.x = x; tmp_.y = y;
- return tmp_;
- }
- vector operator-(vector tmp) {
- float x = this->x - tmp.x;
- float y = this->y - tmp.y;
- if (x < 0)
- x += 7;
- if (y < 0)
- y += 7;
- vector tmp_;
- tmp_.x = x; tmp_.y = y;
- return tmp_;
- }
- int operator--(int n) {
- this->x--;
- this->y--;
- }
- int operator++(int n) {
- this->x++;
- this->y++;
- }
- };
- int main()
- {
- int n = 4;
- vector mass[n];
- for (int i = 0; i < n; i++)
- {
- cout << "Enter " << i+1 << " vector coords: ";
- mass[i].input();
- }
- int n1 = 0, n2 = 1, s = 999999;
- for (int i = 0; i < n - 1; i++)
- for (int j = i + 1; j < n; j++)
- {
- vector tmp = mass[i] + mass[j];
- if (tmp.len()/2 > s)
- {
- n1 = i;
- n2 = j;
- s = tmp.len()/2;
- }
- }
- cout << "Index of elements min sr znachenien: " << n1 << " " << n2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement