debugging suddenly stops
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
for(i =0; i< 2500; i++){
if(i==k){
dist[i]=100000;
continue;}
euc=0;
for(j=0;j<2;j++){
euc+=(v.at(i).at(j)-v.at(k).at(j))*(v.at(i).at(j)-v.at(k).at(j));
euc=sqrt(euc);
}
dist[i]=euc;}
for(i =0; i< 2500; i++){
if(dist[i]<min)
min=dist[i];
n=i;
}
float result= v.at(n).at(3);
cout << "the prediction for the power of the tribune # " << k<<":"<< result<< "\n";
|
program stops debugging suddenly and says "An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in orjin.exe".
Does the debugger not tell you the line that caused the exception?
no it doesn't. but i know where the problem is. the poblem disappears when i delete this line:
float result= v.at(n).at(3);
but how can i call this variable then?
What's the value of n at that point, and what's the size of v?
@OP: learn to indent. And with that I mean don't indent your code because you will mess up.
Let the IDE do it.
Line 14.
Lines 11 to 15 look suspicious.
As written:
1 2 3 4 5 6 7
|
for (i=0; i<2500; i++)
{
if (dist[i] < min)
min = dist[i];
n = i;
}
|
But perhaps this is what was actually supposed to be?
1 2 3 4 5 6 7 8
|
for (i=0; i<2500; i++)
{
if (dist[i] < min)
{
min = dist[i];
n = i;
}
}
|
Topic archived. No new replies allowed.