c语言speed函数怎样 c语言squeeze函数( 二 )


setfillstyle(SOLID_FILL,color);
bar(100-(33-3*num[0].data[num[0].top]),400-20*i-8,100+
(33-3*num[0].data[num[0].top]),400-20*i+8); /*画矩形*/
}
setcolor(YELLOW);
outtextxy(180,450,"any key to continue");
settextstyle(0,0,2);
outtextxy(90,420,"A"); /*塔座标志*/
outtextxy(240,420,"B");
outtextxy(390,420,"C");
getch();/*接收字符后就执行递归操作*/
hanoi('a','b','c',n,num);
}
void move(char x,char y,struct H num[3])/*移动的具体过程*/
{
int i;
char num1[3],num2[3];
sprintf(num1,"%c",x-32);/*将小写变成大写,并转换成字符串输出*/
sprintf(num2,"%c",y-32);
setfillstyle(SOLID_FILL,BLACK);/*把原来的地方移去涂黑*/
bar(0,0,640,60);
setcolor(RED);
outtextxy(150,30,num1);/*输出移动过程*/
outtextxy(200,30,"---");
outtextxy(310,30,num2);
settextstyle(0,0,2);
setfillstyle(SOLID_FILL,BLACK);/*把原来的地方移去涂黑*/
bar(100+150*(x-97)-(33-3*num[x-97].data[num[x-97].top]),
400-20*num[x-97].top-8,100+150*(x-97)+(33-3*
num[x-97].data[num[x-97].top]),400-20*num[x-97].top+8);
num[y-97].top++;/*入栈,目标点的top加1*/
num[y-97].data[num[y-97].top]=num[x-97].data[num[x-97].top];/*在目标点盘子的代号与源点盘子的代号相同*/
num[x-97].top--;/*出栈,原来地方的top减1*/
setfillstyle(SOLID_FILL,num[y-97].data[num[y-97].top]+1);/*盘子颜色代码是栈顶盘子代号加1*/
bar(100+150*(y-97)-(33-3*num[y-97].data[num[y-97].top]),
400-20*num[y-97].top-8,100+150*(y-97)+
(33-3*num[y-97].data[num[y-97].top]),400-20*num[y-97].top+8);
if(computer)/*自动控制就用delay*/
delay(speed);/*延时函数*/
else
getch();/*手动控制的话就自己按键盘来控制*/
}
void hanoi(char one,char two,char three,int n,struct H num[3])/*递归n为盘子数,num为堆栈*/
{
if(n==1)
move(one,three,num);/*如果盘子为1,将这个盘子从塔座A移动到塔座C*/
else
{
hanoi(one,three,two,n-1,num);/*将塔座A的前n-1个盘子移到塔座B*/
move(one,three,num);/*将塔座A的第n个盘子移到塔座C*/
hanoi(two,one,three,n-1,num); /*将塔座B的n-1个盘子移到塔座C*/
}
}
void Close(void)/*图形关闭*/
{
getch();
closegraph();
}
c语言好玩的函数桌面下雪程序:#includewindows.h
#includetime.h
#includestdlib.h
#includeiostream.hconst int SnowNumber=500; //雪点数量struct SnowNode
{
POINT postion;//雪点位置
intiColor; //先前c语言speed函数怎样的颜色
intiSpeed; //下落速度
intiMove; //下落距离
intiStick; //粘贴度
};SnowNode SnowNodes[SnowNumber]; //雪点数组
inthTimer=0;
intCrWind=0;
intCrStep=0; //当前循环步数(用于限速)
intScreenWidth=0;//屏幕宽度
intScreenHeight=0;//屏幕高度void GetScreenSize();
void CALLBACK TimerProc(HANDLE hWnd,UINT uMsg,UINT idEvent,DWORD dwTime);
void InitSnowNodes();
void MoveSnowNodes();int WINAPIWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTRlpCmdLine,
intnCmdShow
)
{
MSG msg; //标准windows消息
LARGE_INTEGER Frequency; //高性能定时器频率
LARGE_INTEGER StartCt,EndCt;//高性能定时器计数
float ElapsedTime;//时间间隔
srand((unsigned)time(NULL));
GetScreenSize();
InitSnowNodes();
QueryPerformanceFrequency(Frequency);
hTimer=SetTimer(0,0,rand()%5*500,(TIMERPROC)TimerProc);
if(hTimer==0)
{
MessageBox(0,TEXT("创建定时器失败"),TEXT("提示"),MB_OK|MB_ICONINFORMATION);
return -1;
}
RegisterHotKey(0,0,MOD_CONTROL,(int)'L');
while(1)
{
QueryPerformanceCounter(StartCt); //执行运算前计数值