#include<graphics.h>
![](/Images/OutliningIndicators/None.gif)
#include"dos.h"
![](/Images/OutliningIndicators/None.gif)
#include "stdio.h"
![](/Images/OutliningIndicators/None.gif)
#include "alloc.h"
![](/Images/OutliningIndicators/None.gif)
int num1,num2,num3,h0,cy[66];
![](/Images/OutliningIndicators/None.gif)
void plot1(int ,int ,int ,int );
![](/Images/OutliningIndicators/None.gif)
void move(char getone,char putone)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif) { int x0=40,x,y,w,h,tx,ty,tw,th,x1,x2,y1,y2,xm1,ym1,xm2,ym2;
![](/Images/OutliningIndicators/InBlock.gif)
int i,n,size;
![](/Images/OutliningIndicators/InBlock.gif)
void *buffer,*buffer1;
![](/Images/OutliningIndicators/InBlock.gif)
switch(getone)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
case 'A':num1--;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'B':num2--;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'C':num3--;break;
![](/Images/OutliningIndicators/InBlock.gif)
default: exit(0);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
switch(putone)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
case 'A':num1++;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'B':num2++;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'C':num3++;break;
![](/Images/OutliningIndicators/InBlock.gif)
default: exit(0);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
switch(getone)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
case 'A':x=120;y1=cy[num1+1]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'B':x=320;y1=cy[num2+1]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'C':x=520;y1=cy[num3+1]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
default: exit(0);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
switch(putone)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
case 'A':tx=120-50;ty=cy[num1]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'B':tx=320-50;ty=cy[num2]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
case 'C':tx=520-50;ty=cy[num3]-h0;break;
![](/Images/OutliningIndicators/InBlock.gif)
default: exit(0);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
x1=x-50;
![](/Images/OutliningIndicators/InBlock.gif)
x2=x+50;
![](/Images/OutliningIndicators/InBlock.gif)
y2=y1+h0;
![](/Images/OutliningIndicators/InBlock.gif)
xm1=(x1+tx)/2;
![](/Images/OutliningIndicators/InBlock.gif)
ym1=(y1+ty)/2;
![](/Images/OutliningIndicators/InBlock.gif)
xm2=xm1+100;
![](/Images/OutliningIndicators/InBlock.gif)
ym2=ym1+h0;
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
size=imagesize(x1,y1,x2,y2);
![](/Images/OutliningIndicators/InBlock.gif)
buffer=malloc(size);
![](/Images/OutliningIndicators/InBlock.gif)
getimage(x1,y1,x2,y2,buffer);
![](/Images/OutliningIndicators/InBlock.gif)
setfillstyle(SOLID_FILL,3);
![](/Images/OutliningIndicators/InBlock.gif)
bar(x1,y1,x2,y2);
![](/Images/OutliningIndicators/InBlock.gif)
setcolor(YELLOW);
![](/Images/OutliningIndicators/InBlock.gif)
line((x1+x2)/2,y1,(x1+x2)/2,y2);
![](/Images/OutliningIndicators/InBlock.gif)
buffer1=malloc(size);
![](/Images/OutliningIndicators/InBlock.gif)
n=abs(tx-x1);
![](/Images/OutliningIndicators/InBlock.gif)
for(i=0;i<n;i+=3)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
xm1=x1+(float)(tx-x1)/n*i;
![](/Images/OutliningIndicators/InBlock.gif)
ym1=y1+(float)(ty-y1)/(tx-x1)*(xm1-x1);
![](/Images/OutliningIndicators/InBlock.gif)
xm2=xm1+100;
![](/Images/OutliningIndicators/InBlock.gif)
ym2=ym1+h0;
![](/Images/OutliningIndicators/InBlock.gif)
getimage(xm1,ym1,xm2,ym2,buffer1);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) putimage(xm1,ym1,buffer,COPY_PUT);/**//* delay(10); */
![](/Images/OutliningIndicators/InBlock.gif)
putimage(xm1,ym1,buffer1,COPY_PUT);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) putimage(tx,ty,buffer,COPY_PUT);/**//* delay(50);*/
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
free(buffer1);
![](/Images/OutliningIndicators/InBlock.gif)
free(buffer);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
void hanoi(int n,char one,char two,char three)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
if(n==1) move(one,three);
![](/Images/OutliningIndicators/InBlock.gif)
else
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
hanoi(n-1,one,three,two);
![](/Images/OutliningIndicators/InBlock.gif)
move(one,three);
![](/Images/OutliningIndicators/InBlock.gif)
hanoi(n-1,two,one,three);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/None.gif)
main()
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
int gdriver,gmode,x0=40,y0=400,x1,x2,x3,y1,y2,y3,x,y,w0=100;
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
int i,num,w,w1;
![](/Images/OutliningIndicators/InBlock.gif)
printf("Please input the number of plate(<=64):");
![](/Images/OutliningIndicators/InBlock.gif)
scanf("%d",&num);
![](/Images/OutliningIndicators/InBlock.gif)
if(num>65)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {printf ("number great than 64 ",exit(0));}
![](/Images/OutliningIndicators/InBlock.gif)
h0=(y0-80)/num;
![](/Images/OutliningIndicators/InBlock.gif)
w1=(100-10)/num;
![](/Images/OutliningIndicators/InBlock.gif)
num1=num;
![](/Images/OutliningIndicators/InBlock.gif)
num2=0;
![](/Images/OutliningIndicators/InBlock.gif)
num3=0;
![](/Images/OutliningIndicators/InBlock.gif)
gdriver=DETECT;
![](/Images/OutliningIndicators/InBlock.gif)
initgraph(&gdriver,&gmode,"");
![](/Images/OutliningIndicators/InBlock.gif)
setfillstyle(SOLID_FILL,3);
![](/Images/OutliningIndicators/InBlock.gif)
bar(0,0,640,480);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) setcolor(15); /**//* white */
![](/Images/OutliningIndicators/InBlock.gif)
line(1,1,637,1);
![](/Images/OutliningIndicators/InBlock.gif)
line(1,1,1,477);
![](/Images/OutliningIndicators/InBlock.gif)
line(0,0,638,0);
![](/Images/OutliningIndicators/InBlock.gif)
line(0,0,0,478);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) setcolor(8); /**//*darkgray */
![](/Images/OutliningIndicators/InBlock.gif)
line(638,2,638,478);
![](/Images/OutliningIndicators/InBlock.gif)
line(639,1,639,479);
![](/Images/OutliningIndicators/InBlock.gif)
line(632,380,632,472);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) setcolor(14); /**//* yellow */
![](/Images/OutliningIndicators/InBlock.gif)
line(x0,401,640-x0,401);
![](/Images/OutliningIndicators/InBlock.gif)
line(x0+80,40,x0+80,400);
![](/Images/OutliningIndicators/InBlock.gif)
line(x0+280,40,x0+280,400);
![](/Images/OutliningIndicators/InBlock.gif)
line(x0+480,40,x0+480,400);
![](/Images/OutliningIndicators/InBlock.gif)
x1=x0+80;
![](/Images/OutliningIndicators/InBlock.gif)
x2=x0+280;
![](/Images/OutliningIndicators/InBlock.gif)
x3=x0+480;
![](/Images/OutliningIndicators/InBlock.gif)
for(x=x1,y=y0,w=w0,i=1;i<=num;i++,y=y-h0-1,w=w-w1)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) {
![](/Images/OutliningIndicators/InBlock.gif)
plot1(x,y,w,h0);
![](/Images/OutliningIndicators/InBlock.gif)
cy[i]=y;
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/InBlock.gif)
setcolor(14);
![](/Images/OutliningIndicators/InBlock.gif)
line(x0+80,40,x0+80,400);
![](/Images/OutliningIndicators/InBlock.gif)
getch();
![](/Images/OutliningIndicators/InBlock.gif)
hanoi(num,'A','B','C');
![](/Images/OutliningIndicators/InBlock.gif)
getch();
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/None.gif)
void plot1(int x,int y,int w,int h)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif) {int x1,x2,y1,y2,xc,yc,a,b;
![](/Images/OutliningIndicators/InBlock.gif)
x1=x-w/2;
![](/Images/OutliningIndicators/InBlock.gif)
x2=x+w/2;
![](/Images/OutliningIndicators/InBlock.gif)
y1=y-h;
![](/Images/OutliningIndicators/InBlock.gif)
y2=y;
![](/Images/OutliningIndicators/InBlock.gif)
xc=(x1+x2)/2;
![](/Images/OutliningIndicators/InBlock.gif)
yc=(y1+y2)/2;
![](/Images/OutliningIndicators/InBlock.gif)
a=w/2;
![](/Images/OutliningIndicators/InBlock.gif)
b=h/2;
![](/Images/OutliningIndicators/InBlock.gif)
setfillstyle(SOLID_FILL,14);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) /**//* bar(x1,y1,x2,y2); */
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) setcolor(14); /**//* yellow */
![](/Images/OutliningIndicators/InBlock.gif)
setlinestyle(0,0,1);
![](/Images/OutliningIndicators/InBlock.gif)
ellipse(xc,yc,0,360,a,b);
![](/Images/OutliningIndicators/InBlock.gif)
floodfill(xc-2,yc,YELLOW);
![](/Images/OutliningIndicators/InBlock.gif)
floodfill(xc+2,yc,YELLOW);
![](/Images/OutliningIndicators/InBlock.gif)
setcolor(1);
![](/Images/OutliningIndicators/InBlock.gif)
ellipse(xc,yc,0,360,a,b);
![](/Images/OutliningIndicators/InBlock.gif)
ellipse(xc,yc,0,360,a-3,b-3);
![](/Images/OutliningIndicators/InBlock.gif)
setfillstyle(SOLID_FILL,12);
![](/Images/OutliningIndicators/InBlock.gif)
floodfill(xc-2,yc+b-2,BLUE);
![](/Images/OutliningIndicators/InBlock.gif)
floodfill(xc+2,yc+b-3,BLUE);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif) /**//* line(x1,y1,x1,y2);
![](/Images/OutliningIndicators/InBlock.gif)
line(x1,y2,x2,y2);
![](/Images/OutliningIndicators/InBlock.gif)
line(x2,y2,x2,y1);
![](/Images/OutliningIndicators/InBlock.gif)
line(x2,y1,x1,y1);
![](/Images/OutliningIndicators/InBlock.gif)
*/
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
|