عندي كود لحل معادلة رياضية
لكن المشكلة ان الكود بلغة سي
واريد تحويل الى لغة فيجوال بيسك
هذا هو الكود ....
#include<stdio.h>
#include<math.h>
define pi 4*atan(1#)
define true 1#
define false 0#
double f(double x);
void INPUT (int *, double * , double * , double * , int *, int *);
void OUTPUT (double, double , int , double *,double );
main ()
{
double W[25], L[25], U[25], Z[25];
double FT, FX, ALPHA, H, K, VV, T, X;
int N, M, M1, M2, N1, FLAG, I1, I, J, OK;
INPUT ( &OK, &FX, &ALPHA, &N, &M);
if (OK)
{
M1 = M - 1;
M2 = M - 2;
N1 = N - 1;
/* Step 1 */
H = FX / M;
K = FT/N;
VV = ALPHA * ALPHA * K / (H * H);
/* Step 2 */
for ( I=1; I<=M1; I++)
W[I-1] = F( I * H );
/* Step 3 */
L[0] = 1.0 + 2.0 * VV;
U[0] = -VV / L[0];
/* Step 4 */
for (I=2; I<=M2; I++)
{
L [I-1] = 1.0 + 2.0 * VV+VV* U[I-2];
U[I-1] = -VV / L[I-1];
}
/*Step 5*/
L[M1-1] = 1.0 + 2.0 * VV + VV* U[M2-1];
/*Step 6*/
for (J=1; J<=N; J++)
{
/* Step 7 */
T = J * K;
Z[0] = W[0] / L[0];
for (I=2; I<=M1; I++)
Z[I-1] = ( W[I-1]+VV*Z[I-2] ) / L[I-1];
W[M1-1] = Z[M1-1];
for (I1=1; I1<=M2; I1++)
{
I = M2 - I1 +1;
W[I-1] = Z[I-1] – U[I-1] * W;
}
}
/* Step 11 */
OUTPUT (FT, X, M1, W, H );
}
/* Step 12 */
return 0;
}
/* Change F for A New Problem */
double F(double X)
{
double f;
f = sin(pi * X);
return f;
}
void INPUT (int *OK, double *FX, double *FT, double *ALPHA, int *N, int *M)
{
int FLAG;
char AA;
printf("This is the Backward – Difference Method For Heat Equation .\n");
printf("Has The Function F Been Created Immediately\n");
printf("preceding the INPUT procedure ? Answer Y Or N.\n");
scanf("\n%c", &AA);
if ((AA == 'Y') || (AA == 'y'))
{
printf(" The lefthand endpoint on the X-Axis is 0.\n);
OK = false*;
while (!(*OK))
{
printf("Input the righthand endpoint on the X-Axis.\n");
scanf("%lf", FX);
if (*FX <= 0.0 )
printf("Must Be Positive Number .\n");
else *Ok = true;
}
OK = false*;
while(!(*OK))
{
printf("Input the Maximum Value Of the Time Variable T.\n");
scanf("%lf", FT);
if (*FT <= 0.0)
printf("Must Be positive Number .\n");
else *Ok = true;
}
printf("Input The Constant Alpha.\n");
scanf("%lf", ALPHA);
OK = false*;
while (!(*OK))
{
printf("input integer m = number of intervals On X-Axis\n");
printf("And N = number of time intervals – separated by a blank.\n");
printf("Note That m must be 3 or larger .\n");
scanf("%d %d", M, N);
if ((*M <= 2) || (*N <= 0)
printf("Numbers Are Not within correct range.\n");
else *OK = true;
}
}
else
{
printf("The Program Will End So That The Function F Can Be Created .\n");
OK = false*;
}
}
void OUTPUT (double FT, double x, int M1, double *W, double H)
{
int I, J, FLAG;
char Name[30];
FILE *OUP;
printf("1.Output On Screen\n");
printf("2.Output On Text File\n");
printf(" please Enter 1 Or 2\n");
scanf("%d", &FLAG);
if (FLAG == 2)
{
printf("Input the File Name In The Form – drive :name.ext\n);
printf("for Example : A:OUTPUT.DTA\n");
scanf("%s", NAME);
OUP = fopen(Name, "w");
}
else OUP = stdout;
fprintf(OUP , "This IS The Backward – DiFFernce Method \n\n");
fprintf(OUP, " I X(I) W(X(I) , %12.6e)\n , FT);
for(I=1;I<=M1;I++)
{
X= I * H;
fprintf (OUP, "%3d %11.8f %14.8f\n", I, X, W[I-1]);
}
fclose (OUP)
}