EVERY TIME I RUN THIS PROGRAMME THE COMPILER SHUTDOWN
TELL ME PLZ WHY
I REALLY WANT TO KNOW
#include<stdio.h>
int main()
{
FILE *il,*cur,*next,*per;
float a[100][50],b[102][102],e[100][50],r[101][51],temp[100][50];
char name[2];
int i,j,k,m,s,counter,w,q;
float face=0.0,edge=0.0,corner=0.0,heatcounter=0.0,hcc=0.0;
long oldtemp,newtemp,delta;
//---------------------------------
for (i=1;i<=31;i++) //create 32 file
{
sprintf(name,"%d.txt",i);
il =fopen(name,"w+");
for(i=0;i<5151;i++)
fprintf(il,"70 ");
}
il=fopen("0.txt","w+");
for(i=0;i<4000;i++)
fprintf(il,"700 ");
//--------------------------------
oldtemp=70;
delta =70;
while (delta>0.01)
{
m=1;
while (m<31) //calclute for 31 file
{
sprintf(name,"%d.txt",m);//open the three files
cur =fopen(name,"r+");
s=m;
s--;
sprintf(name,"%d.txt",s);
per=fopen(name,"r+");
s=m;
s++;
sprintf(name,"%d.txt",s);
next =fopen(name,"r+");
//-----------------------------------------
counter=20; //knowing the size of the file
for(i=1;i<31;i++)
{ if(i==m)
{
break;
}
else
counter++;
}
//------------------------------------------------
for (i=0;i<100;i++) //put the element in 2d array
for (j=0;j<counter;j++)
fscanf(cur ,"%f",&a[i][j]);
for (i=0;i<100;i++) //put the element in 2d array
for (j=0;j<counter-1;j++)
fscanf(per ,"%f",&e[i][j]);
k=100;
if (counter==49)//knowing if it the last file
k=101;
for (i=0;i<k;i++) //put the element in 2d array
for (j=0;j<counter+1;j++)
fscanf(next,"%f",&r[i][j]);
//-------------------------------------------------
i=1;
j=1;
for(q=0;q<100;q++) //corner
{
//face
if (q==0)
b[i-1][0]=70;
else
b[i-1][0]=a[i-1][0];
if(q==99)
b[i+1][0]=a[i][j];
else
b[i+1][0]=a[i+1][j];
b[i][j-1]=e[i][j-1];
b[i][j+1]=a[i][j+1];
b[i][j]=e[i][j];
face=b[i-1][0]+b[i+1][0]+b[i][j-1]+b[i][j+1]+ b[i]
[j];
b[i][j]=r[i][j];
face+=b[i][j];
face/=12.0;
//--------------------------
//edge
if(q==0)
{
b[i-1][j+1]=70;
b[i-1][j-1]=70;
}
else
{
b[i-1][j+1]=a[i-1][j+1];
b[i-1][j-1]=e[i-1][j-1];
}
if (q==99)
{
b[i+1][j-1]=e[i][j];
b[i+1][j+1]=a[i][j];
}
else
{
b[i+1][j-1]=e[i+1][j-1];
b[i+1][j+1]=a[i+1][j+1];
}
b[i+1][j]=e[i+1][j];
b[i-1][j]=e[i-1][j];
b[i][j-1]=e[i][j-1];
b[i][j+1]=e[i][j+1];
edge= b[i-1][j+1]+b[i-1][j-1]+ b[i+1][j-1]
+b[i+1][j+1];
edge+=b[i+1][j]+b[i-1][j]+b[i][j-1]+b[i]
[j+1];
b[i+1][j]=r[i+1][j];
b[i-1][j]=r[i-1][j];
b[i][j-1]=r[i][j-1];
b[i][j+1]=r[i][j+1];
edge+=b[i+1][j]+b[i-1][j]+b[i][j-1]+b[i]
[j+1];
edge/=36.0;
//--------------------------
//corner
b[i-1][j-1]=e[i-1][j-1];
b[i-1][j+1]=e[i-1][j+1];
b[i+1][j-1]=e[i+1][j-1];
b[i+1][j+1]=e[i+1][j+1];
corner=b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b
[i+1][j+1];
b[i-1][j-1]=r[i-1][j-1];
b[i-1][j+1]=r[i-1][j+1];
b[i+1][j-1]=r[i+1][j-1];
b[i+1][j+1]=r[i+1][j+1];
corner+=b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b
[i+1][j+1];
corner/=48.0;
temp[q][0]=face+corner+edge;
hcc+=temp[q][0]; //counter for the corner
i++;
j++;
}
//------------------------------------------------------------------
i=1;
j=1;
for(q=0;q<100;q++) //cells
{
for(w=1;w<counter;w++)
{
//face
if (q==0)
b[i-1][j]=70;
else
b[i-1][j]=a[i-1][j];
if(w==counter-1)
b[i][j+1]=a[i][j];
else
b[i][j+1]=a[i][j+1];
if (q==99)
b[i+1][j]=a[i][j];
else
b[i+1][j]=a[i+1][j];
b[i][j-1]=a[i][j-1];
b[i][j]=e[i][j];
face=b[i-1][0]+b[i+1][0]+b[i][j-1]+b[i][j+1]+ b[i]
[j];
b[i][j]=r[i][j];
face+=b[i][j];
face/=12.0;
//--------------------------
//edge
if(q==0)
{
b[i-1][j+1]=70;
b[i-1][j-1]=70;
}
else
{
b[i-1][j+1]=a[i-1][j+1];
b[i-1][j-1]=a[i-1][j-1];
}
if(w==counter-1)
{
b[i+1][j+1]=a[i][j];
b[i-1][j+1]=a[i][j];
}
else
if(q==99)
{
b[i+1][j+1]=a[i][j];
b[i+1][j-1]=a[i][j];
}
else
{
b[i+1][j-1]=a[i+1][j-1];
b[i+1][j+1]=a[i+1][j+1];
}
b[i+1][j]=e[i+1][j];
b[i-1][j]=e[i-1][j];
b[i][j-1]=e[i][j-1];
b[i][j+1]=e[i][j+1];
edge= b[i-1][j+1]+b[i-1][j-1]+ b[i+1][j-1]
+b[i+1][j+1];
edge+=b[i+1][j]+b[i-1][j]+b[i][j-1]+b[i]
[j+1];
b[i+1][j]=r[i+1][j];
b[i-1][j]=r[i-1][j];
b[i][j-1]=r[i][j-1];
b[i][j+1]=r[i][j+1];
edge+=b[i+1][j]+b[i-1][j]+b[i][j-1]+b[i]
[j+1];
edge/=36.0;
//--------------------------
//corner
if(q==99||w==counter-1)
{
b[i-1][j-1]=a[i][j];
b[i-1][j+1]=a[i][j];
b[i+1][j-1]=a[i][j];
b[i+1][j+1]=a[i][j];
}
else
{
b[i-1][j-1]=e[i-1][j-1];
b[i-1][j+1]=e[i-1][j+1];
b[i+1][j-1]=e[i+1][j-1];
b[i+1][j+1]=e[i+1][j+1];
}
corner=b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b
[i+1][j+1];
b[i-1][j-1]=r[i-1][j-1];
b[i-1][j+1]=r[i-1][j+1];
b[i+1][j-1]=r[i+1][j-1];
b[i+1][j+1]=r[i+1][j+1];
corner+=b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b
[i+1][j+1];
corner/=48.0;
temp[q][w]=face+corner+edge;
heatcounter=temp[q][w];
j++;
}
i++;
j=1;}
//-----------------------------------------------
for(i=0;i<100;i++)
for(j=0;j<counter;j++)
fprintf(cur,"%f",b[i][j]);
m++;
fclose(cur);
fclose(per);
fclose(next);
}
//----------------------------------------------
newtemp=(heatcounter/4900)*16;
newtemp+=(hcc/100)*8;
delta=newtemp-oldtemp;
oldtemp=newtemp;
}
return 0; }
//----------------------------------------------
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
