hmm..i got some trouble on this code which i failed to make an output like tis :
1 0 0 0 0
1 1 0 0 0
1 2 1 0 0
1 3 3 1 0
1 4 6 4 1
Pascal triangle in square.
Here are my code
#include<iostream>
#include<assert.h>
using namespace std;
int main()
{
void build_pascal(int p[][6], int n)
{ assert(n>0 && n < 6);
for (int i =0;i<6;i++)
for (int j=0;j<6;j++)
if (i>n || j>i) p [i][j]=0;
else if (j==0 || j==i)p[i][j]=1;
else p[i][j]= p[i-1][j-1] + p[i-1][j];
}
return 0;
}
error C2601: 'build_pascal' : local function definitions are illegal
#include<iostream>
#include<assert.h>
using namespace std;
void build_pascal(int p[][6], int n)
{ assert(n>0 && n <6);
for (int i =0;i<6;i++)
for (int j=0;j<6;j++)
if (i>n || j>i) p [i][j]=0;
else if (j==0 || j==i)p[i][j]=1;
else p[i][j]= p[i-1][j-1] + p[i-1][j];
}
It compile successfully but when i debugging it shows 2 errors:
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib test
Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\user\Desktop\test\test\Debug\test.exe test