#include <iostream>using namespace std;int V[3]={12,8,5};int src[6] ={0,0,1,1,2,2};int dest[6]={1,2,0,2,0,1};int record[100][3];int rec_index=0;void Pour(int state[],int a,int b){ int r=V[b]-state[b]; if(state[a]<r) {state[b]+=state[a];state[a]=0;} else {state[b]=V[b];state[a]-=r;}}void Output(){ printf(" A B C
"); for(int i=0;i<rec_index;++i) printf("%4d %4d %4d
",record[i][0],record[i][1],record[i][2]); printf("
");}void Record(int state[]){ record[rec_index][0]=state[0]; record[rec_index][1]=state[1]; record[rec_index][2]=state[2]; ++rec_index;}bool Exist(int state[]){ for(int i=0;i<rec_index;++i) if (state[0]==record[i][0] && state[1]==record[i][1] && state[2]==record[i][2]) return true; return false;}void Solve(int state[]){ int a=state[0],b=state[1],c=state[2]; Record(state); if(a==6 && b==6 && c==0) {Output();return;} for(int i=0;i<6;++i) { if(state[src[i]]==0) continue; Pour(state,src[i],dest[i]); if(!Exist(state)) { Solve(state); --rec_index; } state[0]=a;state[1]=b;state[2]=c; }}int main(){ int init[3]={12,0,0}; Solve(init); return 0;}