小弟我不是学计算机的,VC也没有学过啊...只是学过一点TC.....今年大四了,老师说要用VC来模拟什么温度场~~~~考试就考这个....小弟我无奈上来求助!!!!!
请大侠门帮帮忙啊~~~~能不能在下面的程序中有问号"????"的地方帮小弟我注释下是什么意思~~~~~~求求大家了~~~~还希望大家能告诉我这个算出来到底应该是什么????
跪谢~~~~!!!!!
再次跪谢!!!!!!
能解决的朋友希望可以尽快联系我`~~~~~QQ:12559504 (请说明是VC编程的),
若您给的东西有用,本人可以用Q币,IP卡,电话卡,游戏电数卡等酬谢~~~~~~~~
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
#include "string.h"
#define Max_Buffer 250 ????
int Mx, My, Mz;
int *M;
float *dx, *dy, *dz;
double dt;
double *w1, *w2, *w3, *w4, *w5, *w6;
double time=0, deltat=0.1, alpha=0.5, f=2/(deltat*alpha), T0=25, Tt=100;
double *T, *T1;
void readgeo(FILE *fp);
void init();
void Saulyev();
void output();
int main(int argc, char* argv[])
{int flag_run; ????
FILE *fp;
fp = fopen("readgeo.txt", "r");
if( fp == NULL ) ????
{ printf("Can't open readgeo.txt file for reading\n");
exit(1);
}
readgeo (fp);
fclose (fp);
init();
flag_run = 1;
do
{
Saulyev();
time = time + deltat;
if( time > 10 )
flag_run = 0;
}while(flag_run);
output();
return 0;
}
void readgeo(FILE *fp)
{
int i,j,k;
int counter;
int number;
float dimension;
char buffer[Max_Buffer]; ????
size_t size;
fgets(buffer, Max_Buffer, fp); ????
fgets(buffer, Max_Buffer, fp);
sscanf(buffer, "%d", &Mx); ????
printf("Mx = %d\n", Mx);
dx=(float *)malloc(Mx * sizeof(float)); ????
counter = 0;
do
{
fgets(buffer, Max_Buffer, fp); ????
sscanf(buffer, "%d %f", &number, &dimension); ????
for(i=0; i<number; i++)
dx[i+counter] = dimension;
counter += number;
}while( counter < Mx );
fgets(buffer, Max_Buffer, fp);
fgets(buffer, Max_Buffer, fp);
sscanf(buffer, "%d", &My);
printf("My = %d\n", My);
dy=(float *)malloc(My * sizeof(float));
counter = 0;
do
{
fgets(buffer, Max_Buffer, fp);
sscanf(buffer, "%d %f", &number, &dimension);
for(i=0; i<number; i++)
dy[i+counter] = dimension;
counter += number;
}while( counter < My );
fgets(buffer, Max_Buffer, fp);
fgets(buffer, Max_Buffer, fp);
sscanf(buffer, "%d", &Mz);
printf("Mz = %d\n\n", Mz);
dz=(float *)malloc(Mz * sizeof(float)); ?????
counter = 0;
do
{
fgets(buffer, Max_Buffer, fp);
sscanf(buffer, "%d %f", &number, &dimension);
for(i=0; i<number; i++)
dz[i+counter] = dimension;
counter += number;
}while( counter < Mz );
size = Mx*My*Mz*sizeof(int);
M=(int *)malloc(size);
fgets(buffer, Max_Buffer, fp);
for(i=0; i<Mx; i++)
for(j=0; j<My; j++)
for(k=0; k<Mz; k++)
fscanf(fp, "%d", (M+i*My*Mz+j*Mz+k)); ????
for(i=0;i<Mx;i++)
{
for(j=0;j<My;j++)
{
for(k=0;k<Mz;k++)
printf("%d " , *(M+i*My*Mz+j*Mz+k));
printf("\n");
}
printf("\n\n");
}
}
void init(void)
{
int i, j, k;
size_t size;
size = Mx * My * Mz * sizeof (double); ????
T = (double *)malloc(size); ????
T1= (double *)malloc(size); ????
for(i=0; i<Mx; i++)
for(j=0; j<My; j++)
for(k=0; k<Mz; k++)
{
if( *(M+i*My*Mz+j*Mz+k)==1 )
*(T+i*My*Mz+j*Mz+k) = T0;
else
*(T+i*My*Mz+j*Mz+k) = Tt;
}
for(i=0; i<Mx; i++)
for(j=0; j<My; j++)
for(k=0; k<Mz; k++)
*(T1+i*My*Mz+j*Mz+k) = *(T+i*My*Mz+j*Mz+k);
size = Mx * sizeof(double);
w1 = (double *)malloc(size); ????
w2 = (double *)malloc(size); ????
size = My * sizeof(double);
w3 = (double *)malloc(size);
w4 = (double *)malloc(size);
size = Mz * sizeof(double);
w5 = (double *)malloc(size);
w6 = (double *)malloc(size);
for(i=1; i<Mx-1; i++)
{
w1[i] = 2/(dx[i] *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*Mz+j*Mz+k))*w4[j]
+(*(T+i*My*Mz+j*Mz+(k+1))-*(T+i*My*Mz+j*Mz+k))*w5[k]
+(*(T+i*My*Mz+j*Mz+(k-1))-*(T+i*My*Mz+j*Mz+k))*w6[k] )/f;
}
}
}
void output()
{
int i,j,k;
for(i=0;i<Mx;i++)
{
for(j=0;j<My;j++)
{
for(k=0;k<Mz;k++)
{
printf("%6.2f " , *(T+i*My*Mz+j*Mz+k));
}
printf("\n");
}
printf("\n\n");
}
}
下面的文件是放在一个写字板里的~~~就是READGEO.TXT文件里的东西~~~~
Exp Solution
10
10 1
10
10 1
10
10 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 0 1 1 0
0 1 1 0 0 0 0 1 1 0
0 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 0 1 1 0
0 1 1 0 0 0 0 1 1 0
0 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 0 1 1 0
0 1 1 0 0 0 0 1 1 0
0 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
0 0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 1 1 1 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
能解决的朋友希望可以尽快联系我`~~~~~QQ:12559504 (请说明是VC编程的),
若您给的东西有用,本人可以用Q币,IP卡,电话卡,游戏电数卡等酬谢~~~~~~~~
[此贴子已经被作者于2005-12-2 21:53:52编辑过]