int num;
temp1=(m/3)*3;
temp2=(m%3)*3;
num = dataNeedToBeInsert[m][n];
for(i=start;i10;i++)
{
temp3 = temp1+(start-1)/3;
temp4 = temp2+(start-1)%3;
if(jiuGongArray[temp3][temp4]!=0)
{
start++;
continue;
}
if(CheckLine(temp3,temp4,num)!=0)
{
start++;
continue;
}
else
{
*position = start;
return 0;
}
}
return -1;
}
//入栈
int Push(int *top,int xPosition,int yPosition,int jiuGongGePosition,int num)
{
if(*top = MAXSTACKLENGTH)
{
printf("Reach stack top!\n");
return -1;
}
else
{
(*top)++;
stack[*top].xPosition = xPosition;
stack[*top].yPosition = yPosition;
stack[*top].jiuGongGePosition = jiuGongGePosition;
stack[*top].num = num;
return 0;
}
}
//出栈
int Pop(int *top,int *xPosition,int *yPosition,int *jiuGongGePosition,int *num)
{
if(*top == -1)
{
printf("Reach stack bottom!\n");
return -1;
}
else
{
*xPosition = stack[*top].xPosition;
*yPosition = stack[*top].yPosition;
*jiuGongGePosition = stack[*top].jiuGongGePosition;
*num = stack[*top].num;
(*top)--;
return 0;
}
}
void main()
{
int end=0;
int line=0;
int row=0;
int top=-1;
int positionInUnitArray=1;
int state=0;
int num;
FindDataToBeInsert();
PrintArray(jiuGongArray,9,9);
while(end!=1)
{
state = FindNextData(line,row,line,row);
if(state == 0)
{
state = CheckCanPush(line,row,positionInUnitArray);
if(state == 0)
{
state = Push(top,line,row,positionInUnitArray,dataNeedToBeInsert[line][row]);
if(state ==0)
{
jiuGongArray[(line/3)*3+(positionInUnitArray-1)/3][(line%3)*3+(positionInUnitArray-1)%3]=dataNeedToBeInsert[line][row];
row++;
positionInUnitArray = 1;
}
else
end = 1;
}
else
{
state = Pop(top,line,row,positionInUnitArray,num);
if(state == 0)
{
jiuGongArray[(line/3)*3+(positionInUnitArray-1)/3][(line%3)*3+(positionInUnitArray-1)%3] = 0;
positionInUnitArray++;
}
else
end = 1;
}
}
else if(state == 1)
{
printf("\n");
PrintArray(jiuGongArray,9,9);
end = 1;
}
else
{
printf("Some error occur!\n");
end = 1;
}
}
}
【画格子用的c语言函数 画格子用的c语言函数有哪些】画格子用的c语言函数的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于画格子用的c语言函数有哪些、画格子用的c语言函数的信息别忘了在本站进行查找喔 。
推荐阅读
- 京东电商如何避税,京东如何交税
- 本地无法链接mysql数据库,mysql链接远程数据库
- python编程网站加密码,python编写密码加密程序
- jquery的有什么用,jquery用途
- go语言圣经epub go语言圣经 epub
- gis主要的软件部件有等,gis软件包括哪几种类型
- css旋转动画特效代码,旋转 css
- 学跳舞的视频应该下载什么软件,学跳舞视频软件手机版
- 怎么给mysql上传数据 mysql数据库文件怎么发送