小编Avi*_*ash的帖子

C++中的双引号字符串

如何在双引号字符串中转换带空格的字符串.例如:我得到字符串

c:\program files\abc.bat
Run Code Online (Sandbox Code Playgroud)

我想将此字符串转换为" c:\program files\abc.bat",但仅限于字符串中有空格.

c++

3
推荐指数
1
解决办法
576
查看次数

自毁过程Unix C

我想在启动进程后删除可执行文件.

我尝试通过推unlink,它工作正常,但我希望我的可执行文件继续运行.

使用unlink方法是否正确?使用这种方法有什么问题吗?

c unix

3
推荐指数
1
解决办法
145
查看次数

"Sling Blade Runner":找到重叠电影片串的高效算法?

这个问题来自ITA软件归档谜题,因为谜题已经退役,我想可以讨论.

你可以找到一连串重叠的电影片,比如"活着让死亡诗人社会的另一天死去"吗?

我想知道解决这种难题的最佳方法/算法是什么.

puzzle algorithm

3
推荐指数
1
解决办法
566
查看次数

数据流中频繁和前 k 个元素的高效计算

这是pseduo该算法的代码。

空间节省算法

以下是我如何实现这一点。

#include <iostream>
#include <fstream>
#include <string>
#include <map>

typedef std::map<std::string, int> collection_t;
typedef collection_t::iterator collection_itr_t;

collection_t T;

collection_itr_t get_smallest_key() {
    collection_itr_t min_key = T.begin();
    collection_itr_t key     = ++min_key;
    while ( key != T.end() ) {
        if ( key->second < min_key->second )
            min_key =  key;
        ++key;
    }
    return min_key;
}
void space_saving_frequent( std::string &i, int k ) {
    if ( T.find(i) != T.end())
        T[i]++;
    else if ( T.size() < k ) {
        T.insert(std::make_pair(i, 1 ));
    } else …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm

3
推荐指数
1
解决办法
1880
查看次数

生成字符串的所有可能的唯一子字符串

我需要获取字符串的所有唯一子字符串.我已存储串入一个trie,但我不能找出我怎么能使用相同的打印所有例如唯一子

字符串aab所有唯一的子串是{"a", "aa", "aab", "ab", "b"}

这是我的代码 trie

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

struct trie_node_t {
    typedef std::map<char, trie_node_t *> child_node_t;
    child_node_t m_childMap;
    trie_node_t() :m_childMap(std::map<char, trie_node_t*>()) {}

    void insert( std::string& word ) {
        trie_node_t *pNode = this;
        for ( std::string::const_iterator itr = word.begin(); itr != word.end(); ++itr) {
            char letter = *itr;
            if ( pNode->m_childMap.find(letter) == pNode->m_childMap.end()){
                pNode->m_childMap[letter] = new trie_node_t();
            }
            pNode = pNode->m_childMap[letter];
        }
    }

    void print() {
    }
}; …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm data-structures

3
推荐指数
1
解决办法
4906
查看次数

如何在C++ 11中自动实现

如何auto实施C++11?我试过跟随,它的工作原理C++11

auto a = 1;
// auto = double
auto b = 3.14159;
// auto = vector<wstring>::iterator
vector<wstring> myStrings;
auto c = myStrings.begin();
// auto = vector<vector<char> >::iterator
vector<vector<char> > myCharacterGrid;
auto d = myCharacterGrid.begin();
// auto = (int *)
auto e = new int[5];
// auto = double
auto f = floor(b);
Run Code Online (Sandbox Code Playgroud)

我想检查一下如何使用plain来实现 C++

c++ c++11

3
推荐指数
2
解决办法
1157
查看次数

Perl正则表达式找到一个确切的单词

我想sprintf在我的代码中找到这个词.应该使用什么Perl正则表达式?有一些行有文字sprintf_private,我想排除,但只需要sprintf.

regex perl

3
推荐指数
2
解决办法
8967
查看次数

编译器停止使用某些C系统调用的方法

我希望人们停止使用像sprintf被认为是不安全功能的功能.如果sprintf在代码中使用了编译错误,还是有任何其他技巧?

c

3
推荐指数
2
解决办法
233
查看次数

无法将'this'指针从'const container <T>'转换为'container <T>&'

STL compilation error在以下代码中得到了以下内容.

#include <cstdio>
#include <string>

template <typename T>
class container {
public:
  container(std::string in_key="") {
    m_element_index = 0;
  }
  ~container() {
  }
  // Returns the numbers of elements in the container
  int size() {
    return m_element_index;
  }
  // Assignment operator
  // Assigns a copy of container x as the new content for the container object.
  container& operator= (const container& other) {
    if (this != &other) {
      for ( int idx = 0; idx < other.size(); idx++) …
Run Code Online (Sandbox Code Playgroud)

c++ stl

3
推荐指数
1
解决办法
5472
查看次数

算法问题/问题列表

这可能不是编程问题,人们可以关闭.

有没有人有要解决的问题/问题列表,这有助于提高算法技能可能是面试目的.

algorithm

2
推荐指数
1
解决办法
387
查看次数

标签 统计

c++ ×5

algorithm ×4

c ×2

c++11 ×1

data-structures ×1

perl ×1

puzzle ×1

regex ×1

stl ×1

unix ×1