请帮忙调试一个c语言的程序!急急!!

来源:百度知道 编辑:UC知道 时间:2024/06/08 07:37:29
. Finite-difference method for nonlinear ODE
Code:

#include <stdio.h>
#include<math.h>
int main ()
{
//Inputs
double f(double x, double y, double z);
double d2f(double x, double y, double z);
double d3f(double x, double y, double z);
double a, b, tol;
int iter, maxIter, n, i;
float a, b, ya, yb, dy;
printf("Enter the initial (a) and final (b) values of x:");
scanf("%f%f",&a,&b);
printf("Enter boundary values of y at x=a (ya) and x=b (yb):");
scanf("%f%f", &ya,&yb);
printf("Enter number of subdivision n:");
scanf("%f", &n);
float A[3][n+1], y[n+1]; // tridiagonal. We do not use A(.,0)
double h = (b-a)/(n+1);
double alpha = y[0];
double beta = y[n+1];
const int SUBD = 0;
const int DIAG = 1;
const int SUPD = 2;
float B[n+1];
B[0] = 0;
// Initial guess at solution
fo

#include <stdio.h>
#include<stdlib.h>
#include<math.h>
int main ()
{
//Inputs
double f(double x, double y, double z);
double d2f(double x, double y, double z);
double d3f(double x, double y, double z);
double a, b, tol;
int iter, maxIter, n, i;
float ya, yb, dy;//重定义a,b
printf("Enter the initial (a) and final (b) values of x:");
scanf("%f%f",&a,&b);
printf("Enter boundary values of y at x=a (ya) and x=b (yb):");
scanf("%f%f", &ya,&yb);
printf("Enter number of subdivision n:");
scanf("%d", &n);//定义是整形。存的时候又用f??
float A[3][n+1], y[n+1]; // tridiagonal. We do not use A(.,0)
double h = (b-a)/(n+1);
double alpha = y[0];
double beta = y[n+1];
const int SUBD = 0;
const int DIAG = 1;
const int SUPD = 2;
float B[n+1];
B[0] = 0;
// Initial guess at solution
for(i=1; i<