problem in program

Hi
I want to know what is the problem in this program?
I want to have somthing similar this:
1 8 9
2 7 10
3 6 11
4 5 12
the program is:
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,j=0,k,i,m;
	cout<<"Enter the size of your matrix A(m*n).\n";
	cout<<"Enter Row as m:\n";
	cin>>m;
	cout<<"Enter col as n:\n"<<endl;
	cin>>n;
	vector <vector <int> >A(m, vector <int> (n,0));
	while ( j<n)
	{
		if(j==0)
		{
		for(int i=0;i<m;i++)
			{
				A[i][j]=(i+1);
			cout<<A[i][j]<<"\t";
				cout<<endl;
			}
		}
		else if (j%2!=0)
		{
			for (int j,i=m,k=0;i>0;i--,k++)
			{
				A[i][j]=i+(j*m);
			A[k][j]=A[i][j];
			cout<<A[k][j]<<"\t";
			cout<<endl;
			}
		}
		else
		{
			for(int i=0,j;i<m;i++)
			{
				 A[i][j]=(i+1)+(j*m);
				cout<<A[i][j]<<"\t";
				cout<<endl;
			}
		}
j++;
	}
	return 0;
}

thanks so much
First of all, you get a segmentation fault. You go out of bounds on line 28. Your i should go from m-1 to 0. Also, why do you redeclare int j on lines 26 and 36? You don't re-initialize them.
To get the table format that you want, first calculate all elements of A, and then write a loop to output them
Hi dear friend!
At first excuse me for re-initialize int j;dear friend I can't understand why I have segmentation fault & why I go out of bound on line 28.
Can I have your help about them?
(I must say that I'm a beginner in c++;so excuse me for my simple question.thanks.)
Topic archived. No new replies allowed.