2020 day 10 (C): fix for 32 bits architecture (ooops !)
This commit is contained in:
@@ -63,7 +63,6 @@ struct list *add_val(list, val)
|
|||||||
struct list *list;
|
struct list *list;
|
||||||
unsigned long long val;
|
unsigned long long val;
|
||||||
{
|
{
|
||||||
//int val;
|
|
||||||
unsigned cur, size;
|
unsigned cur, size;
|
||||||
unsigned long long *ptr;
|
unsigned long long *ptr;
|
||||||
|
|
||||||
@@ -80,7 +79,6 @@ struct list *add_val(list, val)
|
|||||||
size+=BLOCKSIZE;
|
size+=BLOCKSIZE;
|
||||||
list->size=size;
|
list->size=size;
|
||||||
list->list=realloc(list->list, sizeof(unsigned long long)*size);
|
list->list=realloc(list->list, sizeof(unsigned long long)*size);
|
||||||
fprintf(stderr, "realloc buf: cur=%d size=%d ptr=%p\n", cur, size, list->list);
|
|
||||||
}
|
}
|
||||||
ptr=list->list+cur;
|
ptr=list->list+cur;
|
||||||
|
|
||||||
@@ -91,10 +89,10 @@ struct list *add_val(list, val)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned *calc(list)
|
unsigned long long *calc(list)
|
||||||
struct list *list;
|
struct list *list;
|
||||||
{
|
{
|
||||||
static unsigned res[4];
|
static unsigned long long res[4];
|
||||||
unsigned long long *ptr=list->list;
|
unsigned long long *ptr=list->list;
|
||||||
unsigned last=list->last, i;
|
unsigned last=list->last, i;
|
||||||
|
|
||||||
@@ -113,10 +111,9 @@ int main(ac, av)
|
|||||||
{
|
{
|
||||||
char line[80];
|
char line[80];
|
||||||
struct list *list=NULL;
|
struct list *list=NULL;
|
||||||
unsigned long long res, last;
|
unsigned long long res, last, *result;
|
||||||
unsigned *result;
|
|
||||||
|
|
||||||
list=add_val(list, 0);
|
list=add_val(list, 0llu);
|
||||||
while (fgets(line, sizeof line, stdin)) {
|
while (fgets(line, sizeof line, stdin)) {
|
||||||
sscanf(line, "%llu", &res);
|
sscanf(line, "%llu", &res);
|
||||||
list=add_val(list, res);
|
list=add_val(list, res);
|
||||||
@@ -126,7 +123,7 @@ int main(ac, av)
|
|||||||
list=add_val(list, last+3);
|
list=add_val(list, last+3);
|
||||||
//print_list(list);
|
//print_list(list);
|
||||||
result=calc(list);
|
result=calc(list);
|
||||||
printf("%s : diff1=%u diff2=%u res=%u\n", *av, result[1], result[3],
|
printf("%s : diff1=%llu diff2=%llu res=%llu\n", *av, result[1], result[3],
|
||||||
result[1]*result[3]);
|
result[1]*result[3]);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
@@ -131,7 +131,7 @@ int main(ac, av)
|
|||||||
struct list *list=NULL;
|
struct list *list=NULL;
|
||||||
unsigned long long res, last;
|
unsigned long long res, last;
|
||||||
|
|
||||||
list=add_val(list, 0);
|
list=add_val(list, 0ll);
|
||||||
while (fgets(line, sizeof line, stdin)) {
|
while (fgets(line, sizeof line, stdin)) {
|
||||||
sscanf(line, "%llu", &res);
|
sscanf(line, "%llu", &res);
|
||||||
list=add_val(list, res);
|
list=add_val(list, res);
|
||||||
|
Reference in New Issue
Block a user