强劲的风 2022-03-02 22:57 采纳率: 0%
浏览 542

vscode c++ debug时new_allocator.h文件报错,请大家帮我看看,感激不尽!

报错处:

[::operator delete(__p);
}

  size_type
  max_size() const _GLIBCXX_USE_NOEXCEPT
  { return size_t(-1) / sizeof(_Tp); }

img

写的代码:

#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        vector<vector<string>> ans;
        unordered_map<string,vector<string>> result;//hash表,拥有相同key的存储在一起
        for(int i = 0; i < strs.size(); i++)
        {
            result[MyHash(strs[i])].push_back(strs[i]);//先计算key,再根据key将str[i]添加到散列表中
        }
        for(auto &iter :result)
        {
            ans.push_back(iter.second);//将散列表中处理好的变位词添加到二维向量ans中
        }
       //这里直接输出其实也可以,但是写了方法,想用返回结果后输出
        /*vector<string> temp_vect;
        for (vector<vector<string>>::iterator ite = ans.begin(); ite != ans.end(); ite++)
        {
            temp_vect = *ite;//一维一维输出
            for (vector<string>::iterator itee = temp_vect.begin(); itee != temp_vect.end(); itee++)
                cout << *itee<<" ";
            cout << endl;
        }*/
        //system("pause");
        return ans;
        
    }
    string MyHash(string s)
    {
        string key= string(26, '0'); // length = 26
        for(int i = 0; i < s.size(); i++)
        {
            key[s[i]-'a'] ++;
        }
        return key;
    }
};

int main()
{
    Solution s;
    vector<vector<string>> ans1;
    vector<string> str;//存储读入的单词
    ifstream inf;
    inf.open("D:\\Desktop\\test.txt");//读入单词文件
    string file;
    while(getline(inf,file))//一行一行读入
    {
        string tmp;
        for(int k=0; k<file.size();)
        {
            if(file[k]==' '||file[k]==','||file[k]=='.'||k==file.size()-1)
            {
                str.push_back(tmp);
                k++;
                tmp.clear();
            }
            if(file[k]!=' ')//去除前置空格
                tmp.push_back(file[k]);
            k++;
        }
    }
    
    ans1=s.groupAnagrams(str);//得到已处理好的变位词,二维向量表
    vector<string> temp_vect;
    //遍历输出
    for (vector<vector<string>>::iterator ite = ans1.begin(); ite != ans1.end(); ite++)
    {
        temp_vect = *ite;//一维一维输出
        for (vector<string>::iterator itee = temp_vect.begin(); itee != temp_vect.end(); itee++)
            cout << *itee<<" ";
        cout << endl;
    }
    system("pause");
}



测试文本用例:
There were a sensitivity and a beauty to her that have nothing to do with looks.She was one to be listened to, whose words were so easy to take to heart.
It is said that the true nature of being is veiled. The labor of words, the expression of art, the seemingly ceaseless buzz that is human thought all have in common the need to get at what really is so. The hope to draw close to and possess the truth of being can be a feverish one. In some cases it can even be fatal, if pleasure is one's truth and its attainment more important than life itself. In other lives, though, the search for what is truthful gives life.
I used to find notes left in the collection basket, beautiful notes about my homilies and about the writer's thoughts on the daily scriptural readings. The person who penned the notes would add reflections to my thoughts and would always include some quotes from poets and mystics he or she had read and remembered and loved. The notes fascinated me. Here was someone immersed in a search for truth and beauty. Words had been treasured, words that were beautiful. And I felt as if the words somehow delighted in being discovered, for they were obviously very generous to the as yet anonymous writer of the notes. And now this person was in turn learning the secret of sharing them. Beauty so shines when given away. The only truth that exists is, in that sense, free.
It was a long time before I met the author of the notes.
One Sunday morning, I was told that someone was waiting for me in the office. The young person who answered the rectory door said that it was "the woman who said she left all the notes." When I saw her I was shocked, since I immediately recognized her from church but had no idea that it was she who wrote the notes. She was sitting in a chair in the office with her hands folded in her lap. Her head was bowed and when she raised it to look at me, she could barely smile without pain. Her face was disfigured, and the skin so tight from surgical procedures that smiling or laughing was very difficult for her. She had suffered terribly from treatment to remove the growths that had so marred her face.
We chatted for a while that Sunday morning and agreed to meet for lunch later that week.
As it turned out we went to lunch several times, and she always wore a hat during the meal. I think that treatments of some sort had caused a lot of her hair to fall out. We shared things about our lives. I told her about my schooling and growing up. She told me that she had worked for years for an insurance company. She never mentioned family, and I did not ask.
We spoke of authors we both had read, and it was easy to tell that books are a great love of hers.
I have thought about her often over the years and how she struggled in a society that places an incredible premium on looks, class, wealth and all the other fineries of life. She suffered from a disfigurement that cannot be made to look attractive. I know that her condition hurt her deeply.
Would her life have been different had she been pretty? Chances are it would have. And yet there were a sensitivity and a beauty to her that had nothing to do with looks. She was one to be listened to, whose words were so easy to take to heart. Her words came from a wounded but loving heart, very much like all hearts, but she had more of a need to be aware of it, to live with it and learn from it. She possessed a fine-tuned sense of beauty. Her only fear in life was the loss of a friend.
How long does it take most of us to reach that level of human growth, if we ever get there? We get so consumed and diminished, worrying about all the things that need improving, we can easily forget to cherish those things that last. Friendship, so rare and so good, just needs our care-maybe even the simple gesture of writing a little note now and then, or the dropping of some beautiful words in a basket, in the hope that such beauty will be shared and taken to heart.
The truth of her life was a desire to see beyond the surface for a glimpse of what it is that matters. She found beauty and grace and they befriended her, and showed her what is real.



  • 写回答

1条回答 默认 最新

  • 真相重于对错 2022-03-03 09:59
    关注

    学会调试

    评论

报告相同问题?

问题事件

  • 创建了问题 3月2日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘