C++のdequeを使って8パズルを幅優先探索で解こうとしています。
まずdequeの使い方を学ぼうと簡単なプログラムを作ってみたのですが、
エラーが発生してしまいました。どこがおかしいか教えていただければ幸いです。あと8パズルをdequeで解く指針などもよろしければお願いします。
#include <string.h>
#include <deque>
#include<iostream>
#define MAX_STATE 181440//状態数の合計
#define SIZE 9//マスの数
int init_state[SIZE]={1,2,3,4,5,6,7,8,0};//スタート
int final_state[SIZE]={1,2,3,4,5,6,7,0,8};//ゴール
std::deque<int[SIZE]> state;//状態を格納するdeque
void bfs(){
state.push_front(init_state);
state.push_back(final_state);
std::cout<<state[0];
std::cout<<state[1];
}
int main(void){
bfs();
return 0;
}
エラー内容 visual studioでやっています
1>------ ビルド開始: プロジェクト: tansaku, 構成: Debug Win32 ------
1> tansaku.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(48): error C2075: 'Target of operator new()' : 配列の初期化には中かっこ ({}) が必要です。
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(197) : コンパイルされたクラスの テンプレート のインスタンス化 'void std::_Construct<int[9],const int(&)[9]>(_Ty1 (),_Ty2)' の参照を確認してください
1> with
1> [
1> _Ty1=int [9],
1> _Ty2=const int (&)[9]
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(196): クラス テンプレート のメンバー関数 'void std::allocator<_Ty>::construct(int ()[9],const _Ty (&))' のコンパイル中
1> with
1> [
1> _Ty=int [9]
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\deque(721) : コンパイルされたクラスの テンプレート のインスタンス化 'std::allocator<_Ty>' の参照を確認してください
1> with
1> [
1> _Ty=int [9]
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\deque(773) : コンパイルされたクラスの テンプレート のインスタンス化 'std::_Deque_val<_Ty,_Alloc>' の参照を確認してください
1> with
1> [
1> _Ty=int [9],
1> _Alloc=std::allocator<int [9]>
1> ]
1> z:\visual studio 2010\projects\tansaku\tansaku\tansaku.cpp(12) : コンパイルされたクラスの テンプレート のインスタンス化 'std::deque<_Ty>' の参照を確認してください
1> with
1> [
1> _Ty=int [9]
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory(48): fatal error C1903: 直前のエラーを修復できません。コンパイルを中止します。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。