//ħ·½³ÌÐò#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>//Êý¾Ý½á¹¹£ºtypedefenumcolors{blue=1,red,yellow,green,white,orange}Colors;//6ÖÖÑÕÉ«typedefstructsurface{Colorss[4][4];}Surface;//ÿ¸öÃæÓÐ3*3¸öС¸ñ£¬´Óϱê1¿ªÊ¼±íʾ£¬Ã¿Ò»ÃæµÄÑÕÉ«Êǹ̶¨µÄtypedefstructcube{Surfaceup,down,front,back,left,right;}Cube;//ħ·½µÄ6¸öÃætypedefstructsnode{char*chbuf;inttimes;structsnode*next;}SNode;typedefstructsequence{SNode*head;//´æ´¢Ä§·½×ª»»ÐòÁÐintnum;//ħ·½×ª»»µÄ´ÎÊý}Sequence;SequenceCD;//³ÌÐò£ºvoidSaveChBuf(char*sur,inti)//½«cbÐòÁдæÈëchbufÖÐ{char*str;intlen=strlen(sur);SNode*p,*q;if(i%4){str=(char*)malloc(sizeof(char)*(len+2));if(!str){printf("ÄÚ´æ²»×ã!\n");exit(0);}strcpy(str,sur);q=(SNode*)malloc(sizeof(SNode));if(!q){printf("ÄÚ´æ²»×ã!\n");exit(0);}q->chbuf=str;q->times=i;q->next=NULL;if(CD.head==NULL){CD.head=q;CD.num++;}else{for(p=CD.head;p->next;p=p->next);if(!strcmp(p->chbuf,q->chbuf)){p->times=(p->times+q->times)%4;free(q->chbuf);free(q);if(!(p->times)){if(p==CD.head){CD.head=NULL;free(p->chbuf);free(p);CD.num--;}else{for(q=CD.head;q->next!=p;q=q->next);q->next=NULL;free(p->chbuf);free(p);CD.num--;}}}else{p->next=q;CD.num++;}}}}voidclockwise(Surface*sur,inti)//½«surÃæ˳ʱÕëÐýתi´Î{Surfacet;for(;i>0;i--){t=*sur;sur->s[1][1]=t.s[3][1];sur->s[1][2]=t.s[2][1];sur->s[1][3]=t.s[1][1];sur->s[2][1]=t.s[3][2];sur->s[2][2]=t.s[2][2];sur->s[2][3]=t.s[1][2];sur->s[3][1]=t.s[3][3];sur->s[3][2]=t.s[2][3];sur->s[3][3]=t.s[1][3];}}voidF(Cube*m,inti)//½«Ä§·½µÄÕýÃæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->front,1);m->right.s[1][1]=n.up.s[3][1];m->right.s[2][1]=n.up.s[3][2];m->right.s[3][1]=n.up.s[3][3];m->down.s[1][1]=n.right.s[3][1];m->down.s[1][2]=n.right.s[2][1];m->down.s[1][3]=n.right.s[1][1];m->left.s[1][3]=n.down.s[1][1];m->left.s[2][3]=n.down.s[1][2];m->left.s[3][3]=n.down.s[1][3];m->up.s[3][1]=n.left.s[3][3];m->up.s[3][2]=n.left.s[2][3];m->up.s[3][3]=n.left.s[1][3];}}voidB(Cube*m,inti)//½«Ä§·½µÄ±³Ãæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->back,1);m->right.s[1][3]=n.down.s[3][3];m->right.s[2][3]=n.down.s[3][2];m->right.s[3][3]=n.down.s[3][1];m->down.s[3][1]=n.left.s[1][1];m->down.s[3][2]=n.left.s[2][1];m->down.s[3][3]=n.left.s[3][1];m->left.s[1][1]=n.up.s[1][3];m->left.s[2][1]=n.up.s[1][2];m->left.s[3][1]=n.up.s[1][1];m->up.s[1][1]=n.right.s[1][3];m->up.s[1][2]=n.right.s[2][3];m->up.s[1][3]=n.right.s[3][3];}}voidR(Cube*m,inti)//½«Ä§·½µÄÓÒÃæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->right,1);m->up.s[1][3]=n.front.s[1][3];m->up.s[2][3]=n.front.s[2][3];m->up.s[3][3]=n.front.s[3][3];m->front.s[1][3]=n.down.s[1][3];m->front.s[2][3]=n.down.s[2][3];m->front.s[3][3]=n.down.s[3][3];m->down.s[1][3]=n.back.s[3][1];m->down.s[2][3]=n.back.s[2][1];m->down.s[3][3]=n.back.s[1][1];m->back.s[3][1]=n.up.s[1][3];m->back.s[2][1]=n.up.s[2][3];m->back.s[1][1]=n.up.s[3][3];}}voidL(Cube*m,inti)//½«Ä§·½µÄ×óÃæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->left,1);m->up.s[1][1]=n.back.s[3][3];m->up.s[2][1]=n.back.s[2][3];m->up.s[3][1]=n.back.s[1][3];m->back.s[1][3]=n.down.s[3][1];m->back.s[2][3]=n.down.s[2][1];m->back.s[3][3]=n.down.s[1][1];m->down.s[1][1]=n.front.s[1][1];m->down.s[2][1]=n.front.s[2][1];m->down.s[3][1]=n.front.s[3][1];m->front.s[1][1]=n.up.s[1][1];m->front.s[2][1]=n.up.s[2][1];m->front.s[3][1]=n.up.s[3][1];}}voidU(Cube*m,inti)//½«Ä§·½µÄÉÏÃæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->up,1);m->front.s[1][1]=n.right.s[1][1];m->front.s[1][2]=n.right.s[1][2];m->front.s[1][3]=n.right.s[1][3];m->right.s[1][1]=n.back.s[1][1];m->right.s[1][2]=n.back.s[1][2];m->right.s[1][3]=n.back.s[1][3];m->back.s[1][1]=n.left.s[1][1];m->back.s[1][2]=n.left.s[1][2];m->back.s[1][3]=n.left.s[1][3];m->left.s[1][1]=n.front.s[1][1];m->left.s[1][2]=n.front.s[1][2];m->left.s[1][3]=n.front.s[1][3];}}voidD(Cube*m,inti)//½«Ä§·½µÄµ×Ãæ˳ʱÕëתi´Î{Cuben;for(;i>0;i--){n=*m;clockwise(&m->down,1);m->front.s[3][1]=n.left.s[3][1];m->front.s[3][2]=n.left.s[3][2];m->front.s[3][3]=n.left.s[3][3];m->left.s[3][1]=n.back.s[3][1];m->left.s[3][2]=n.back.s[3][2];m->left.s[3][3]=n.back.s[3][3];m->back.s[3][1]=n.right.s[3][1];m->back.s[3][2]=n.right.s[3][2];m->back.s[3][3]=n.right.s[3][3];m->right.s[3][1]=n.front.s[3][1];m->right.s[3][2]=n.front.s[3][2];m->right.s[3][3]=n.front.s[3][3];}}voidMR(Cube*m,inti)//½«Ä§·½µÄ×óÃæºÍÓÒÃæÖ®¼äµÄÃæÒÔÓÒÃæΪ»ù׼˳ʱÕëÐýת1´Î{Cuben;for(;i>0;i--){n=*m;m->up.s[1][2]=n.front.s[1][2];m->up.s[2][2]=n.front.s[2][2];m->up.s[3][2]=n.front.s[3][2];m->front.s[1][2]=n.down.s[1][2];m->front.s[2][2]=n.down.s[2][2];m->front.s[3][2]=n.down.s[3][2];m->down.s[1][2]=n.back.s[3][2];m->down.s[2