- Notifications
You must be signed in to change notification settings - Fork 117
/
Copy path119.c
31 lines (29 loc) · 622 Bytes
/
119.c
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
#include<stdio.h>
#include<stdlib.h>
int*getRow(introwIndex) {
intk=rowIndex;
int*ans= (int*)calloc(k+1, sizeof(int));
inti, j;
intprev=0, cur=0;
ans[0] =1;
for (i=1; i<k+1; i++) {
prev=ans[0];
for (j=1; j<i; j++) {
cur=ans[j];
ans[j] +=prev;
prev=cur;
}
ans[i] =1;
}
returnans;
}
intmain() {
intk=5;
int*ans=getRow(k);
inti;
for (i=0; i<k+1; i++) {
printf("%d ", ans[i]);
}
printf("\n");
return0;
}