コード例 #1
0
ファイル: 00101.cpp プロジェクト: a5216652166/coding
int main(void){
	char cmd[5], mode[5];
	int b1,b2;
	scanf("%d\n",&nBlock);
	struct block*b[nBlock];
	for(int i = 0; i < nBlock; i++){
		b[i] = new block;
		b[i]->v = b[i]->pile = i;
		b[i]->abo = b[i]->bel = NULL;
	}
	while(true){
		scanf("%s ",&cmd);
		if(strcmp(cmd,"quit")==0) break;		
		scanf(" %d %s %d\n",&b1,&mode,&b2);
		if(b1 == b2 || b[b1]->pile == b[b2]->pile) continue;
		if(strcmp(cmd,"move")==0){
			if(strcmp(mode,"onto")==0) moveOnto(b[b1],b[b2]);
			else moveOver(b[b1],b[b2]);
		}
		else if(strcmp(mode,"onto")==0) pileOnto(b[b1],b[b2]);
		else pileOver(b[b1],b[b2]);
	}
	showeet(b);
	return 0;
}
コード例 #2
0
ファイル: 101.cpp プロジェクト: rich1983/ProgrammingPuzzle
int main()
{
  int n, i, a, b;
  char ins[5], mod[5];

  while(1 == scanf("%d",&n))
  {
    for(i=0;i<n;i++) {pos[i] = i; stack[i].length = 1; stack[i].container[0] = i;}
    
    while(scanf("%s",ins) && 'q' != ins[0])
    {
      scanf("%d %s %d", &a, mod, &b);
      if(a == b || pos[a] == pos[b]) {continue;}

      if('m' == ins[0] ) { 'o' == mod[3] ? moveOnto(a, b) : moveOver(a,b); }
      else               { 'o' == mod[3] ? pileOnto(a, b) : pileOver(a,b); }
    }
    showAll(n);
  }

  return 0;
}