C语言_getcwd函数 c语言getenv函数(11)


{
s[man.y][man.x-2]=2;
s[man.y][man.x-1]=4;
s[man.y][man.x]=0;
}
else
{
continue;
}
}
else if(s[man.y][man.x-1]==0 || s[man.y][man.x-1]==3)
{
s[man.y][man.x-1]=4;
s[man.y][man.x]=0;
}
else
{
continue;
}
}
int i;
for(i=0;inest_count;i++)
{
if(nest[i].x==prev.xnest[i].y==prev.y)
{
s[prev.y][prev.x]=3;
break;
}
}
Draw();
if(is_Success()==true)
{
gate++;
if(gatemap_count)
{
printf("\n\nmap is end!");
fflush(stdin);
getch();
exit(0);
}
break;
}
}
else if(sel=='q' || sel=='Q')
{
exit(0);
}
else if(sel=='r' || sel=='R')
{
break;
}
}
}
return 0;
}
void GetDataFromFile()
{
int i;
if(s!=NULL)
{
if(h!=0)
{
for(i=0;ih;i++)
{
free(s+i);
}
free(s);
}
else
{
printf("fail");
getch();
exit(0);
}
}
if(nest!=NULL)
{
free(nest);
}
map_count=GetPrivateProfileInt("MAPCOUNT","map_count",0,data_file);
if(map_countgate)
{
printf("gate finish!");
getch();
exit(0);
}
char section[20]={'\0'};
sprintf(section,"MAP%d",gate);
nest_count=GetPrivateProfileInt(section,"nest_count",0,data_file);
nest=(PT*)malloc(sizeof(PT)*nest_count);
w=GetPrivateProfileInt(section,"w",0,data_file);
h=GetPrivateProfileInt(section,"h",0,data_file);
if(w5 || h5 || nest_count1)
{
printf("w or h or box_nest data error!");
getch();
exit(0);
}
s=(int**)malloc(sizeof(int*)*h);
for(i=0;ih;i++)
{
*(s+i)=(int*)malloc(sizeof(int)*w);
}
char key[20]={'\0'};
char line[50]={'\0'};
int len;
int j;
for(i=0;ih;i++)
{
memset(line,'\0',50);
sprintf(key,"l%d",i+1);
GetPrivateProfileString(section,key,"\0",line,50,data_file);
len=strlen(line);
if(len0)
{
line[len++]=' ';
line[len]='\0';
}
GetIntFromLineString(line,strlen(line),i);
}
len=0;
for(i=0;ih;i++)
{
for(j=0;jw;j++)
{
if(s[i][j]==3)
{
nest[len].y=i;
nest[len].x=j;
len++;
}
else if(s[i][j]==5)
{
nest[len].y=i;
nest[len].x=j;
len++;
s[i][j]=2;
}
}
}
}
void strmyncpy(char* source, char* target, int begin, int end)
{
int i=0;
while(1)
{
if(source[begin]!=' ')
{
target[i]=source[begin];
}
i++;
begin++;
if(beginend)
{
target[i]='\0';
break;
}
}
}
void GetIntFromLineString(char* ch, int len, int i)
{
int j=0;
char c[5]={'\0'};
int b=0,e=0;
while(elen)
{
if(ch[e]==' ')
{
memset(c,'\0',5);
strmyncpy(ch,c,b,e);
b=e+1;
e++;
s[i][j++]=atoi(c);
}
e++;
}
}
void Draw()
{
int i,j,k;
bool flag=false;
system("cls");
printf("\n\n");
for(i=0;ih;i++)
{
printf("\n\n");
for(j=0;jw;j++)
{
if(s[i][j]==0)
{
printf("");
}
else if(s[i][j]==1)
{
printf(" ■ ");
}
else if(s[i][j]==2)
{
printf("

推荐阅读