| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 544 人关注过本帖
标题:[求助]解释下这个调用程序啊
只看楼主 加入收藏
yuzhe
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-6
收藏
 问题点数:0 回复次数:9 
[求助]解释下这个调用程序啊
我是个初学者,有谁能帮我解释下下面这个魔方程序的调用函数具体是讲什么的啊 ,自己不是很懂诶
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
int a[3][3]={1,1,1,1,1,1,1,1,1}; /*INITIALIZE SIX PLANS*/
int b[3][3]={2,2,2,2,2,2,2,2,2};
int c[3][3]={4,4,4,4,4,4,4,4,4};
int d[3][3]={3,3,3,3,3,3,3,3,3};
int e[3][3]={5,5,5,5,5,5,5,5,5};
int f[3][3]={7,7,7,7,7,7,7,7,7};
int top[3][3],front[3][3],side[3][3];
int position=0,temp[3]={0,0,0},new[3][3]; /*POSITION ASSIGN THE ARROW POSITION*/
int sign;
搜索更多相关主题的帖子: 魔方 解释 int 
2007-07-10 21:15
windflush
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:886
专家分:0
注 册:2007-7-1
收藏
得分:0 
他有调用什么吗?

2007-07-10 21:23
ml342418175
Rank: 1
等 级:新手上路
威 望:1
帖 子:183
专家分:0
注 册:2007-4-13
收藏
得分:0 
全部打出来看看呢

做人要洒脱一点,潇洒一点!
2007-07-10 23:56
yuzhe
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-6
收藏
得分:0 

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
int a[3][3]={1,1,1,1,1,1,1,1,1}; /*INITIALIZE SIX PLANS*/
int b[3][3]={2,2,2,2,2,2,2,2,2};
int c[3][3]={4,4,4,4,4,4,4,4,4};
int d[3][3]={3,3,3,3,3,3,3,3,3};
int e[3][3]={5,5,5,5,5,5,5,5,5};
int f[3][3]={7,7,7,7,7,7,7,7,7};
int top[3][3],front[3][3],side[3][3];
int position=0,temp[3]={0,0,0},new[3][3]; /*POSITION ASSIGN THE ARROW POSITION*/
int sign;
main()
{
int l=60,x=50,y=50,key,count,input=0,errorcode; /*L MEANS THE LENTH OF THE SQUARE,X MEANS THE INITAIL POSITION OF X,Y MEANS THE INITIAL POSITION OF Y*/
int a1[3][3]={1,1,1,1,1,1,1,1,1}; /*INITIALIZE SIX PLANS FOR BACKUP*/
int b1[3][3]={2,2,2,2,2,2,2,2,2};
int c1[3][3]={4,4,4,4,4,4,4,4,4};
int d1[3][3]={3,3,3,3,3,3,3,3,3};
int e1[3][3]={5,5,5,5,5,5,5,5,5};
int f1[3][3]={7,7,7,7,7,7,7,7,7};
int graphdriver=VGA,graphmode=VGAHI;
initgraph(&graphdriver,&graphmode,"");
errorcode = graphresult();
if (errorcode != grOk) /*MEET ERROR*/
{ /*SHOW THE ERROE*/
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to exit:");
getch();
exit(1);
}
drawing(x,y,l); /*DRAWING THE BIG SQUARE*/
drawing(x+400,y,l/2); /*DRAWING THE SMALL SQUARE*/
do
{
sign=position%3; /*COPY DATA TO SHOW*/
copy (&a,&top);
copy (&b,&front);
copy (&c,&side);
color(x,y,l); /*SHOWING THE BIG SQUARE*/
copy (&e,&top);
change2(&top,1);
copy (&f,&front);
change2(&front,2);
copy (&d,&side);
color(x+400,y,l/2); /*SHOWING THE SMALL SQUARE*/
setcolor(14);
arrow(x,y,l);
key=bioskey(0); /*READ KEYBORD*/
switch(key)
{
case 283:printf("Esc"); /*IF INPUT_KEY="ESC" TO EXIT THE PROGRAM*/
goto end;
case 20480:setcolor(0); /*IF INPUT_KEY="DOWN" TO CHANGE THE ARROW*/
arrow(x,y,l);
if(position==8)
position=0;
else
position=position+1;
break; /*IF INPUT_KEY="UP" TO CHANGE THE ARROW*/
case 18432:setcolor(0);
arrow(x,y,l);
if(position==0)
position=8;
else
position=position-1;
break;
case 19712:input=1; /*IF INPUT_KEY="RIGHT" TO MOVE FORWARD*/
break;
case 19200:input=3; /*IF INPUT_KEY="LEFT" TO MOVE REWARD*/
break;
case 7181: setcolor(0); /*IF INPUT_KEY="ENTER" TO RELOAD */
arrow(x,y,l);
copy(&a1,&a);
copy(&b1,&b);
copy(&c1,&c);
copy(&d1,&d);
copy(&e1,&e);
copy(&f1,&f);
position=0;
break;
case 14624:setcolor(0); /*IF INPUT_KEY="SPACE" TO RANDOM MOVE*/
arrow(x,y,l);
randomize();
position=random(9);
input=1;
break;
}
if(input!=0) /*USE POSITION TO JUDGE AND CHANGE DATA*/
{ /*IF INPUT=0,CHANGE CLOCKWISE,IF INPUT=3,CHANGE REVERSE-CLOCKWISE*/
for(count=0;count<input;count++)
{
if(position/3==0) /*IF NEED TO CHANGE TOP*/
{
change2(&b,1);
change2(&c,1);
change2(&d,3);
change2(&f,1);
change1(&b,&c);
change1(&c,&d);
change1(&d,&f);
change1(&f,&b);
change2(&b,3);
change2(&c,3);
change2(&d,1);
change2(&f,3);
temp[0]=0;temp[1]=0;temp[2]=0;
if(position%3==0)
change2(&a,1);
if(position%3==2)
change2(&e,1);
}

if(position/3==1) /*IF NEED TO CHANGE FRONT*/
{
change1(&a,&b);
change1(&b,&e);
change1(&e,&d);
change1(&d,&a);
temp[0]=0;temp[1]=0;temp[2]=0;
if(position%3==0)
change2(&f,1);
if(position%3==2)
change2(&c,1);
}

if(position/3==2) /*IF NEED TO CHANGE SIDE*/
{
change2(&a,3);
change2(&e,1);
change2(&f,2);
change1(&a,&c);
change1(&c,&e);
change1(&e,&f);
change1(&f,&a);
change2(&a,1);
change2(&e,3);
change2(&f,2);
temp[0]=0;temp[1]=0;temp[2]=0;
if(position%3==0)
change2(&b,1);
if(position%3==2)
change2(&d,1);
}
}
input=0;
}
}
while(1);
end:
clearviewport(); /*CLEAR THE SCREEN*/
}

drawing(int inital_x,int inital_y,int lenth) /*DRAWING THE STRUCTURE OF THE PICTURE*/
{
setlinestyle(0,0,3);
line(inital_x+1.5*lenth,inital_y+0,inital_x+4.5*lenth,inital_y+0);
line(inital_x+1.0*lenth,inital_y+0.5*lenth,inital_x+4.0*lenth,inital_y+0.5*lenth);
line(inital_x+0.5*lenth,inital_y+1*lenth,inital_x+3.5*lenth,inital_y+1*lenth);
line(inital_x+0,inital_y+1.5*lenth,inital_x+3*lenth,inital_y+1.5*lenth);
line(inital_x+0,inital_y+2.5*lenth,inital_x+3*lenth,inital_y+2.5*lenth);
line(inital_x+0,inital_y+3.5*lenth,inital_x+3*lenth,inital_y+3.5*lenth);
line(inital_x+0,inital_y+4.5*lenth,inital_x+3*lenth,inital_y+4.5*lenth);
line(inital_x+0,inital_y+1.5*lenth,inital_x+0,inital_y+4.5*lenth);
line(inital_x+1.0*lenth,inital_y+1.5*lenth,inital_x+1.0*lenth,inital_y+4.5*lenth);
line(inital_x+2.0*lenth,inital_y+1.5*lenth,inital_x+2.0*lenth,inital_y+4.5*lenth);
line(inital_x+3.0*lenth,inital_y+1.5*lenth,inital_x+3.0*lenth,inital_y+4.5*lenth);
line(inital_x+3.5*lenth,inital_y+1.0*lenth,inital_x+3.5*lenth,inital_y+4.0*lenth);
line(inital_x+4.0*lenth,inital_y+0.5*lenth,inital_x+4.0*lenth,inital_y+3.5*lenth);
line(inital_x+4.5*lenth,inital_y+0,inital_x+4.5*lenth,inital_y+3.0*lenth);
line(inital_x+1.5*lenth,inital_y+0,inital_x+0,inital_y+1.5*lenth);
line(inital_x+2.5*lenth,inital_y+0,inital_x+1.0*lenth,inital_y+1.5*lenth);
line(inital_x+3.5*lenth,inital_y+0,inital_x+2.0*lenth,inital_y+1.5*lenth);
line(inital_x+4.5*lenth,inital_y+0,inital_x+3.0*lenth,inital_y+1.5*lenth);
line(inital_x+4.5*lenth,inital_y+1.0*lenth,inital_x+3.0*lenth,inital_y+2.5*lenth);
line(inital_x+4.5*lenth,inital_y+2.0*lenth,inital_x+3.0*lenth,inital_y+3.5*lenth);
line(inital_x+4.5*lenth,inital_y+3.0*lenth,inital_x+3.0*lenth,inital_y+4.5*lenth);
}
color(int inital_x,int inital_y,int lenth) /*FILL COLOR BY THE DATA*/
{
int i,j;
int color_num;
int x1=inital_x+1.5*lenth;
int y1=inital_y+0.25*lenth;
int x2,y2;
for (i=0;i<3;i++)
{
x2=x1;
y2=y1;
for (j=0;j<3;j++)
{
color_num=top[i][j];
setfillstyle(1,color_num);
floodfill(x2,y2,WHITE);
x2=x2+lenth;
}
x1=x1-0.5*lenth;
y1=y1+0.5*lenth;
}
x1=inital_x+0.5*lenth;
y1=inital_y+2*lenth;
for (i=0;i<3;i++)
{
x2=x1;
y2=y1;
for (j=0;j<3;j++)
{
color_num=front[i][j];
setfillstyle(1,color_num);
floodfill(x2,y2,WHITE);
x2=x2+lenth;
}
y1=y1+lenth;
}
x1=inital_x+3.25*lenth;
y1=inital_y+2*lenth;
for (i=0;i<3;i++)
{
x2=x1;
y2=y1;
for (j=0;j<3;j++)
{
color_num=side[i][j];
setfillstyle(1,color_num);
floodfill(x2,y2,WHITE);
x2=x2+0.5*lenth;
y2=y2-0.5*lenth;
}
y1=y1+lenth;
}
}
arrow(int inital_x,int inital_y,int lenth) /*DRAWING THE ARROW BY THE POSITION*/
{
if(position<=2)
{
line(inital_x-30,inital_y+2*lenth-3+position*lenth,inital_x-20,inital_y+2*lenth-3+position*lenth);
line(inital_x-30,inital_y+2*lenth+3+position*lenth,inital_x-20,inital_y+2*lenth+3+position*lenth);
line(inital_x-21,inital_y+2*lenth-6+position*lenth,inital_x-15,inital_y+2*lenth+position*lenth);
line(inital_x-21,inital_y+2*lenth+6+position*lenth,inital_x-15,inital_y+2*lenth+position*lenth);
}
if(position<=5&&position>2)
{
line(inital_x+0.5*lenth+(position-3)*lenth-3,inital_y+4.5*lenth+30,inital_x+0.5*lenth+(position-3)*lenth-3,inital_y+4.5*lenth+20);
line(inital_x+0.5*lenth+(position-3)*lenth+3,inital_y+4.5*lenth+30,inital_x+0.5*lenth+(position-3)*lenth+3,inital_y+4.5*lenth+20);
line(inital_x+0.5*lenth+(position-3)*lenth-6,inital_y+4.5*lenth+21,inital_x+0.5*lenth+(position-3)*lenth,inital_y+4.5*lenth+15);
line(inital_x+0.5*lenth+(position-3)*lenth+6,inital_y+4.5*lenth+21,inital_x+0.5*lenth+(position-3)*lenth,inital_y+4.5*lenth+15);
}
if(position>5)
{
line(inital_x+3.25*lenth+(position-6)*lenth*0.5-3+5,inital_y+4.5*lenth+30-(position-5)*0.5*lenth+20,inital_x+3.25*lenth+(position-6)*0.5*lenth-3+5,inital_y+4.5*lenth+20-(position-5)*0.5*lenth+20);
line(inital_x+3.25*lenth+(position-6)*lenth*0.5+3+5,inital_y+4.5*lenth+30-(position-5)*0.5*lenth+20,inital_x+3.25*lenth+(position-6)*0.5*lenth+3+5,inital_y+4.5*lenth+20-(position-5)*0.5*lenth+20);
line(inital_x+3.25*lenth+(position-6)*lenth*0.5-6+5,inital_y+4.5*lenth+21-(position-5)*0.5*lenth+20,inital_x+3.25*lenth+(position-6)*0.5*lenth+5,inital_y+4.5*lenth+15-(position-5)*0.5*lenth+20);
line(inital_x+3.25*lenth+(position-6)*lenth*0.5+6+5,inital_y+4.5*lenth+21-(position-5)*0.5*lenth+20,inital_x+3.25*lenth+(position-6)*0.5*lenth+5,inital_y+4.5*lenth+15-(position-5)*0.5*lenth+20);
}
}
copy (int *p,int *q)
{
int i,j;
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
*q=*p;
p++;
q++;
}
}
}
change1(int *p,int *q) /*CONVERT TWO ARRAY*/
{
int i,ling;
p=p+sign;
q=q+sign;
if (temp[0]==0)
{
for(i=0;i<3;i++)
{
temp[i]=*p;
p=p+3;
}
p=p-9;
}
for(i=0;i<3;i++)
{
ling=*q;
*q=temp[i];
temp[i]=ling;
p=p+3;
q=q+3;
}
}
change2(int *p,int x) /*CHANGE THE ARRAY BY REVERSE-CLOCKWISE*/
{
int i,j,k;
for (k=0;k<x;k++)
{
for(i=0;i<3;i++)
{
for(j=2;j>=0;j--)
{
new[j][i]=*p;
p=p+1;
}
}
p=p-9;
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
*p=new[i][j];
p++;
}
}
p=p-9;
}
}



2007-07-11 13:29
shixiaokun86
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2007-5-26
收藏
得分:0 

2007-07-11 13:51
ml342418175
Rank: 1
等 级:新手上路
威 望:1
帖 子:183
专家分:0
注 册:2007-4-13
收藏
得分:0 

好象跟CPU有关,我这里无法运行


做人要洒脱一点,潇洒一点!
2007-07-11 21:56
luo328028280
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2007-7-4
收藏
得分:0 

2007-07-11 22:13
huangfengchu
Rank: 1
等 级:新手上路
威 望:2
帖 子:274
专家分:0
注 册:2007-5-22
收藏
得分:0 
交换地址

深山苦学C语言,终年不见外面世界。
2007-07-11 22:22
柳翔
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-7-9
收藏
得分:0 
回复:(windflush)他有调用什么吗?
这个程序很牛B啊……
2007-07-11 22:35
taiwai1234
Rank: 1
来 自:原始森林神农架
等 级:新手上路
帖 子:64
专家分:0
注 册:2007-6-25
收藏
得分:0 
太强了!我一个都没看懂!

逍遥自在,一生无求!
2007-07-11 23:28
快速回复:[求助]解释下这个调用程序啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017857 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved