我编C++的栈时,出现了问题


#include<iostream>
#include<stack>
#include<string>

using namespace std;

stack<int> mystack;
string a;
int n, js = 0;

int main(){
    cin >> n;
    for(int i = 1;i <= n;i ++){
        a = i;
        while(i > 0){
            mystack.push(i % 10);
            i /= 10;
        }
        for(int j = mystack.size() - 1;j > 0;j --){
            if(a[j] == mystack.top()){
                js ++;
                mystack.pop();
            }
        }
        if(js == mystack.size()){
            cout << i << endl;
        }
    }
    return 0;
}

我用Mingw编译的,
运行时出现了这样的错误:
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libstdc++-v3/include/bits/basic_string.h:1067: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]: Assertion '__pos <= size()' failed.

该怎样改正,谢谢!!

是不是要配c++11的编译机制。https://www.cnblogs.com/flowingwind/p/8449805.html