#include <stdio.h>#include <math.h>#include <malloc.h>#define MAX_SIZE 100float** Runge_Kutta_2(void(*func), float t, float h, float init);float func_test(float t, float y){ float a = (float)(exp(-y)); float b = (float)(t * t); printf("%f %f %f\n",a,b,t); return (a-b);}int main() { float** p; p = Runge_Kutta_2(func_test, 10.0f, 0.001f, 0.0f);}float** Runge_Kutta_2(float(*func)(), float t, float h, float init){ float* Y, *T; float* P[2]; float K1 = 0, K2 = 0, K = 0, time = 0; int k=0,num=1; Y = (float*)malloc(MAX_SIZE * sizeof(float)); T = (float*)malloc(MAX_SIZE * sizeof(float)); Y[0] = init, T[0] = 0; while (time <= t - h) { K1 = func(time, Y[k]); K2 = func(time + h, Y[k] + h * K1); printf("%f\n", time + h); time += h; //printf("%f %f\n", Y[k], T[k]); (*(Y+k+1)) = (*(Y+k)) + h / 2 * (K1 + K2); (*(T + k + 1)) = time; k++; if (k == MAX_SIZE * num - 1) { num++; Y = realloc(Y, num * MAX_SIZE); T = realloc(T, num * MAX_SIZE); } } P[0] = Y,P[1] = T; return P;}