ModSim: s/born/new/g

parent 6e8b5ad9
...@@ -7,32 +7,33 @@ void sequence(int n, int max_age) { ...@@ -7,32 +7,33 @@ void sequence(int n, int max_age) {
long long mature = 0, long long mature = 0,
died = 0; died = 0;
long long *new = malloc((n+1) * sizeof(long long)); long long *born = malloc((n+1) * sizeof(long long));
printf("size: %d\n", sizeof(long long));
printf("popu:"); printf("popu:");
new[0] = 1; born[0] = 1;
printf(" 1"); printf(" 1");
for( i = 1; i < n; i++ ) { for( i = 1; i < n; i++ ) {
died = i < max_age ? 0 : new[i - max_age]; died = i < max_age ? 0 : born[i - max_age];
new[i] = mature; born[i] = mature;
mature = mature + new[i - 1] - died; mature = mature + born[i - 1] - died;
printf(" %lld", mature + new[i]); printf(" %lld", mature + born[i]);
} }
new[i] = mature; born[i] = mature;
puts(""); puts("");
//printf("diff: "); printf("diff: ");
//for( i = 1; i < n; i++ ) for( i = 1; i < n; i++ )
// printf(" %lld", new[i]); printf(" %lld", born[i]);
//puts(""); puts("");
free(new); free(born);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment