vectors

Hi
Last edited on
Declare a minimal value to the first pair of coordinates. Then compare it with other points using i-counter in a for-loop. If (pair < min) min = pair. Multimap associative container can be used to make pair. You can use usual static array point[x][y] too.
Last edited on
It's exemplary scheme using static array (without multimap pair):
1
2
3
4
5
6
7
8
9
min =point[1][1];
for (i = 2; i <= n; i++) {
      for (j = 2; j <= n; j++) {

  if (a[i] [j] > min) min = a[i] [j];

  }
}
printf("minimal coordinates: %i\n",min);
Last edited on
the point with the lowest side

What does that mean?
I've considered that it's point with minimal coordinates. Is it?
yes it is, but i have to work withe vectors not arrays
"Minimal" as in what? Closest to point (0,0)? Or perhaps (-1000,2) is "less" than (0,1)?

Vector is just a dynamic, sugar-coated array. Its documentation on this site has examples of use.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct Point {
  float x;
  float y;
};

bool lower( Point a, Point b ) {
  // return true if a is lower than b
}

int main() {
  std::ifstream fin("input.txt");
  Point p;
  std::vector<Point> data;
  data.reserve(50);
  while ( fin >> p.x >> p.z ) {
    // append p to data
  }
  if ( /*data has points*/ ) {
    std::sort( begin(data), end(data), lower );
    // show the winner
  }
  return 0;
}

minimial as the lowest one in all the points in the file
Topic archived. No new replies allowed.