Language: C++

#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

char str[8];
char fin[8]={0,1,2,3,4,5,6,7};
int dir[4]={-1,1,-4,4};

struct stat={
    char temp[8];
    int num;
    stat(char* tt, int nn){
        for(int i=0; i<8; i++) temp[i]==tt[i];
        num =nn;
    }
}
bool equal(char* p1, char* p2){
    for(int i=0; i<8; i++){
            if(p1[i]!=p2[i]) return false;
    }
    return true;
}

int bfs(char* s){
    queue<stat> q;
    q.push(stat(s, 0));
    
    while(q.size()){
        stat cur=q.front(); q.pop();
        if(equal(cur.temp,fin)) return cur.step;
        int zx;
        for(int i=0; i<8; i++){ if(cur.temp[i]=='0') {zx=i; break;}}
        for(int i=0; i<4; i++){
            int nx = zx+dir[i];
            if(nx>=0&& nx<8){
                char t[8];
                strcpy(t, cur.temp);
                char a=t[zx]; t[zx]=t[nx]; t[nx]=a;
                q.push(stat(t, cur.step+1));
            }
        }
    }
}

int main(){
    while(cin>>str){
        cout<<bfs(str)<<endl;
    }   
}


Compiler output:
a.cc:10:12: error: expected unqualified-id before '=' token
   10 | struct stat={
      |            ^
a.cc: In function 'int bfs(char*)':
a.cc:27:21: error: invalid use of incomplete type 'struct stat'
   27 |     q.push(stat(s, 0));
      |                     ^
a.cc:10:8: note: forward declaration of 'struct stat'
   10 | struct stat={
      |        ^~~~
a.cc:30:14: error: variable 'stat cur' has initializer but incomplete type
   30 |         stat cur=q.front(); q.pop();
      |              ^~~
a.cc:38:17: error: 'strcpy' was not declared in this scope
   38 |                 strcpy(t, cur.temp);
      |                 ^~~~~~
a.cc:4:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc:40:42: error: invalid use of incomplete type 'struct stat'
   40 |                 q.push(stat(t, cur.step+1));
      |                                          ^
a.cc:10:8: note: forward declaration of 'struct stat'
   10 | struct stat={
      |        ^~~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::_M_destroy_data(iterator, iterator, const std::allocator<_CharT>&) [with _Tp = stat; _Alloc = std::allocator<stat>; iterator = std::_Deque_base<stat, std::allocator<stat> >::iterator]':
/usr/include/c++/14/bits/stl_deque.h:1028:24:   required from 'std::deque<_Tp, _Alloc>::~deque() [with _Tp = stat; _Alloc = std::allocator<stat>]'
 1028 |       { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11:   required from here
   96 |     class queue
      |           ^~~~~
/usr/include/c++/14/bits/stl_deque.h:2094:14: error: invalid use of incomplete type 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
 2094 |         if (!__has_trivial_destructor(value_type))
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
   10 | struct stat={
      |        ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::pop_front() [with _Tp = stat; _Alloc = std::allocator<stat>]':
/usr/include/c++/14/bits/stl_queue.h:319:13:   required from 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
  319 |         c.pop_front();
      |         ~~~~~~~~~~~^~
a.cc:30:34:   required from here
   30 |         stat cur=q.front(); q.pop();
      |                             ~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1578:47: error: invalid use of incomplete type 'struct stat'
 1578 |             != this->_M_impl._M_start._M_last - 1)
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:10:8: note: forward declaration of 'struct stat'
   10 | struct stat={
      |        ^~~~
/usr/include/c++/14/bits/stl_deque.h:1582:38: error: cannot increment a pointer to incomplete type 'stat'
 1582 |             ++this->_M_impl._M_start._M_cur;
      |               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(std::size_t) [with _Tp = stat; _Alloc = std::allocator<stat>; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:460:9:   required from 'std::_Deque_base<_Tp, _Alloc>::_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
  460 |       { _M_initialize_map(0); }
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7:   required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
  855 |       deque() = default;
      |       ^~~~~
a.cc:26:17:   required from here
   26 |     queue<stat> q;
      |                 ^
/usr/include/c++/14/bits/stl_deque.h:641:69: error: invalid application of 'sizeof' to incomplete type 'stat'
  641 |       const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp))
      |                                                                     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:672:60: error: invalid application of 'sizeof' to incomplete type 'stat'
  672 |                                         % __deque_buf_size(sizeof(_Tp)));
      |                                                            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)':
/usr/include/c++/14/bits/stl_deque.h:1269:40:   required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
 1269 |       { return this->_M_impl._M_finish - this->_M_impl._M_start; }
      |                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22:   required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
  223 |       { return c.size(); }
      |                ~~~~~~^~
a.cc:29:17:   required from here
   29 |     while(q.size()){
      |           ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:374:25: error: invalid use of incomplete type 'struct stat'
  374 |           + (__x._M_cur - __x._M_first)
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
   10 | struct stat={
      |        ^~~~
/usr/include/c++/14/bits/stl_deque.h:375:26: error: invalid use of incomplete type 'struct stat'
  375 |           + (__y._M_last - __y._M_cur);
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
   10 | struct stat={
      |        ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_deallocate_node(_Ptr) [with _Tp = stat; _Alloc = std::allocator<stat>; _Ptr = stat*]':
/usr/include/c++/14/bits/stl_deque.h:700:2:   required from 'void std::_Deque_base<_Tp, _Alloc>::_M_destroy_nodes(_Map_pointer, _Map_pointer) [with _Tp = stat; _Alloc = std::allocator<stat>; _Map_pointer = stat**]'
  700 |         _M_deallocate_node(*__n);
      |         ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:622:4:   required from 'std::_Deque_base<_Tp, _Alloc>::~_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
  622 |           _M_destroy_nodes(this->_M_impl._M_start._M_node,
      |           ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7:   required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
  855 |       deque() = default;
      |       ^~~~~
a.cc:26:17:   required from here
   26 |     queue<stat> q;
      |                 ^
/usr/include/c++/14/bits/stl_deque.h:590:60: error: invalid application of 'sizeof' to incomplete type 'stat'
  590 |         _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
      |                                                            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'static std::size_t std::_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size() [with _Tp = stat; _Ref = stat&; _Ptr = stat*; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:372:39:   required from 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)'
  372 |         return difference_type(_S_buffer_size())
      |                                ~~~~~~~~~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1269:40:   required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
 1269 |       { return this->_M_impl._M_finish - this->_M_impl._M_start; }
      |                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22:   required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
  223 |       { return c.size(); }
      |                ~~~~~~^~
a.cc:29:17:   required from here
   29 |     while(q.size()){
      |           ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:132:33: error: invalid application of 'sizeof' to incomplete type 'stat'
  132 |       { return __deque_buf_size(sizeof(_Tp)); }
      |                                 ^~~~~~~~~~~