having problem with making a programm hellp me!! please!

this code runes fine until i enter in the values.
it crashes for some reason. I get something like debug assertion failed!.
here is the link for the description for the program
http://acm.pku.edu.cn/JudgeOnline/problem?id=2859
and here's my code.
#include <iostream>
#include <vector>
#include <cmath>

int iPoints;

double x_length;
double y_length;

int x;
int y;
int num = 0;

void main() {
using namespace std;
cout << "How many points?" << endl;
cin >> iPoints;
cout << "How long is the width of the Rectangle?" << endl;
cin >> x_length;
cout << "How long is the height of the Rectangle?" << endl;
cin >> y_length;
vector<double> x_coord;
vector<double> y_coord;
for(int i = 0; i < iPoints; ++i){
cout << "x-coord of point " << i+1 << endl;
cin >> x;
cout << "y-coord of point " << i+1 << endl;
cin >> y;
x_coord.push_back(x);
y_coord.push_back(y);
}

int num = 0;
for (int i = 0 ; i < iPoints ; ++i){
for (int j = i + 1 ; j < iPoints ; ++i){
if (abs(x_coord[i] - x_coord[j]) == x_length){
if (abs(y_coord[i] - y_coord[j]) == y_length){
++num;
}
}
}
}



std::cout << "Number of possible rectangles is " << num << "." << std::endl;
std::cin.get();
return;
}



please help me~
thank you very much
Last edited on
You can post formatted code using the Code Format tag in the lower right of the screen. It would be helpful if you edited your post and formatted the code.

Despite that you should look at these lines:
1
2
for (int i = 0 ; i < iPoints ; ++i){
    for (int j = i + 1 ; j < iPoints ; ++i){


The inner loop shouldn't increment i, I assume that's a typo.
Are you trying to declare num twice?
Topic archived. No new replies allowed.