<一维非稳态导热问题计算程序>能编译成功并生成可执行文件,但不能运行???
#include <stdlib.h>#include <stdio.h>
#include <conio.h>
#include <math.h>
double proc(int DT,int N,double A[],double C[],double B[],double D[],double T[])
{
double P[20],Q[20],F;
int i;
// double T[20];
P[1]=-C[1]/B[1];
Q[1] = D[1] / B[1];
for(i=2;i<N;i++)
{ F = B[i] + A[i] * P[i - 1];
Q[i] = (D[i] - A[i] * Q[i - 1]) / F;
scanf("%lf",&Q[i]);
P[i] = -C[i] / F;
scanf("%lf",&P[i]);
}
for(i=N-1;i>0;i--)
{ T[i] = Q[i] + P[i] * T[i + 1]; //22
// scanf("%lf",T[i]);
}
return T[i];
}
void main()
{
int N,ID,M,DT,i,IR,AT;
double A[20],C[20],T[20]; //32
double X,L[20],TE,B[20],D[20];
printf("Çëêäèë½úμãμÄ×üêy:N\n");
scanf("%d",&N);
printf("ÇëêäèëË2ì¬μü′ú′Îêy:ID\n");
scanf("%d",&ID);
printf("êäèëÎTῸùêy£o M\n");
scanf("%d",&M);
printf("êäèëÎTῸùê±¼ä2½3¤fe : DT\n");
scanf("%d", &DT);
X = 1.0 / (N - 2);
L[1] = 0; L[2] = 0.5 * X;
for (i = 3; i<=N - 1;i++)
{
L[i] = L[i - 1] + X;
scanf("%lf",&L[i]);
}
L[N] = L[N - 1] + 0.5 * X;
IR = 0; AT = 0;
for( i = 1 ;i<= N;i++)
{
T[i] = 1.0;
scanf("%lf",&T[i]);
}
while (IR <= ID)
{
IR = IR + 1;
AT = AT + DT; TE = 1.0 / DT; //61
for (i = 2 ;i<= N - 1;i++)
{
A[i] = 1.0;
scanf("%lf",&A[i]);
C[i] = 1.0;
scanf("%lf",&C[i]);
B[i] = -(2 + M * M * X * X + TE);
scanf("%lf",&B[i]);
D[i] = -TE * T[i];
scanf("%lf",&D[i]); //71
}
C[1] = 2.0; scanf("%lf",&C[1]) ; B[1] = -(2 + M * M * X * X); scanf("%lf",&B[1]);
A[2] = 2.0; B[2] = B[2] - 1; B[N - 1] = B[2];
C[N - 1] = 2.0;
B[N] = 1.0; D[N] = 1.0;scanf("%lf",&B[N]);scanf("%lf",&D[N]);
proc (DT,N,A,C,B,D,T);
printf("IR=%d",IR);
printf(" X*");
printf(" T*\n");
for(i=1;i<=N;i++)
{ if (i!=10)
{
printf("X(%d)=",i);
printf("%10f",L[i]);
printf("%15lf\n",T[i]);
}
else
{printf("X(%d)=",i);
printf("%10f",L[i]);
printf("%15lf\n",T[i]);
printf("\n");
}
}
}
}