Help, please, with a basic array/vector error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <math.h>
#include <conio.h>
#include <iomanip>

using namespace std;

double x[50] = {0.0};
int j, M=5, N=1;
double P[350][350] = {0.0};

int main()
{
for (j = -M; j < M; j++)
P[N][j] = j+1;

for (j = -M+1; j < M; j++)
{ 
x[j] = (1*j)*P[N][j] + (j*(P[N][j+1] + P[N][j-1]));
cout << endl << " x= " << x[j] << endl;
}

getch();
return 0;
}
[/code]

It will run when I change the for loop to a postive number, but it will not work with " j = -M+1). thanks
Last edited on
Could you let us know what you are wanting it to do?
The code (as above) actualy compiles and runs (using VS 2005), so it's difficult to suggest changes without knowing your aim:-)
@pyramidork
what kind of compiler do u use?
as @Faldrax said, it runs with VS 2005

Thanks for replies. Using bloodshed dev++. The output screen freezes and will not execute the "x[j] =" statement.
Topic archived. No new replies allowed.