#include #include #include #ifndef M_PI #define M_PI 3.141592654 #endif typedef struct complex { double r, m; } complex; complex add(complex a, complex b) { a.r += b.r; a.m += b.m; return a; } complex sub(complex a, complex b) { a.r -= b.r; a.m -= b.m; return a; } complex mul(complex a, complex b) { complex result; result.r = a.r*b.r - a.m*b.m; result.m = a.r*b.m + a.m*b.r; return result; } complex* fft (complex* a, int n, int type) { complex *a0, *a1, *y0, *y1, *y, w, wn, t; int i; if (n == 1) { return a; } wn.r = cos(2*M_PI/n); wn.m = type*sin(2*M_PI/n); w.r = 1; w.m = 0; a0 = (complex*)malloc(sizeof(complex)*(n/2)); a1 = (complex*)malloc(sizeof(complex)*(n/2)); y = (complex*)malloc(sizeof(complex)*n); /* for (k = 0; k < n_2; k++) { a_even[k] = a[k<<1]; a_odd[k] = a[(k<<1)+1]; } */ for (i = 0; i "); scanf ("%d", &n1); printf ("Степень второго многочлена -> "); scanf ("%d", &n2); for (n=2; n<=n1+n2; n*=2); a = (complex*)malloc(sizeof(complex)*n); b = (complex*)malloc(sizeof(complex)*n); for (i=0; i<=n1; i++) { printf("a[%d] -> ", i); scanf("%lf", &(a[i].r)); a[i].m = 0; } for (i = n1+1; i ", i); scanf("%lf", &(b[i].r)); b[i].m = 0; } for (i = n2+1; i= 0) { printf("c[%d] = %.0lf\n", i, (a[i].r/n)); i--; } printf("\n"); free(y1); free(y2); free(a); free(b); return 0; }