the problem with the pascal triangle

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
#include <iostream>
using namespace std;
#define x 10

int main()
{
        
	int i,j;
	int a[x][x];
 	for(i=0;i<x;i++)
	{
		a[i][0]=1;
	} 
	for(i=1;i<x;i++)
	{ 
		for(j=1;j<x;j++)
	   {
	a[i][j]=0;
	    }
	}
	for(i=0;i<x;i++)
	{
		for(j=i;j>0;j--)
		{
	      a[i][j]=a[i-1][j-1]+a[i-1][j];
		  cout<<a[i][j];
		  cout<<"n/"<<endl;
}
	cout<<"n/"<<endl;
	}
	system("pause");
	return 0;
}





the output is that
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
47
48
49
50
51
52
53
54
55
56
n/
-858993459n/
n/
-858993459n/
-858993458n/
n/
-858993459n/
-1717986917n/
-858993457n/
n/
-858993459n/
1717986920n/
1717986922n/
-858993456n/
n/
-858993459n/
858993461n/
-858993454n/
858993466n/
-858993455n/
n/
-858993459n/
2n/
7n/
12n/
11n/
-858993454n/
n/
-858993459n/
-858993457n/
9n/
19n/
23n/
-858993443n/
-858993453n/
n/
-858993459n/
-1717986916n/
-858993448n/
28n/
42n/
-858993420n/
-1717986896n/
-858993452n/
n/
-858993459n/
1717986921n/
1717986932n/
-858993420n/
70n/
-858993378n/
1717986980n/
1717986948n/
-858993451n/
n/
Press any key to continue . . .
You have to be more specific. What is wrong with the output and what is the expected output?
1) line end is '\n' not 'n/' and why do you need double line ends? (\n and endl)
2) line 14: for(i=1;i<x;i++) should be for(i=0;i<x;i++)
thanks, I got it.
Topic archived. No new replies allowed.