Ultra-large number margin algorithm

xiaoxiao2021-03-06  23

This program uses array storage results, so it is still limited by array capacity.

If the intermediate result of the use of the linked list is used to improve its order, the step of calculating the array is large, as long as your memory is enough!

#include "stdafx.h" #include "stdio.h" #include "malloc.h"

Const max = 1000; Void PNext (int A [】, int K) {INT * B, M = a [0], i, j, r, carry; b = (int *) malloc (sizeof (int) * ( M 1));

For (i = 1; i <= m; i ) b [i] = a [i]; for (j = 1; j

} void showa (int * a, int K) {INT i; printf ("% 4d! =", k); for (i = a [0]; i> 0; I -) Printf ("% D" , A [I]); Printf ("/ n / n");}

INT Main (int Argc, char * argv []) {Int a [max], n, k; printf ("INPUT N:"); scanf ("% d", & n); a [0] = 1; A [1] = 1; SHOWA (a, 1); for (k = 2; k <= n; k ) {PNEXT (A, K); SHOWA (A, K);} return 0;}

转载请注明原文地址:https://www.9cbs.com/read-39623.html

New Post(0)