|
|
вернуться в форумMemory limit exceeded #include <stdlib.h> #include <stdio.h> #include <math.h> #define DOUBLES_NUM 64 #define int64 long long typedef struct list { long double nums[DOUBLES_NUM]; struct list *prev; } list; int main() { unsigned char ind = 0; unsigned int64 temp; list *temppl, *pl = malloc(sizeof(list)); pl->prev = NULL; while(scanf("%I64", &temp) != EOF) { pl->nums[ind] = sqrt((long double) temp); if(++ind >= DOUBLES_NUM - 1) { temppl = malloc(sizeof(list)); temppl->prev = pl; pl = temppl; ind = 0; } } while(1) { while(ind--) printf("%.4Lf\n", pl->nums[ind]); if(pl->prev == NULL) { free(pl); break; } temppl = pl->prev; free(pl); pl = temppl; ind = DOUBLES_NUM; } return 0; } Why? what you done? these is ver simple input will like this while(cin >> n) { } and array a[1024*128] Re: what you done? I know that reading input could be done much simpler. What I don't understand is why it uses over 16MB of memory. Edited by author 18.07.2010 00:49 |
|
|