c++
Yi__9930
这个作者很懒,什么都没留下…
展开
-
LeetCode 204.计数质数
统计所有小于非负整数 n 的质数的数量。 class Solution { public: int countPrimes(int n) { if(n < 2) return 0; vector<int> hash(n, 1); hash[0] = 0; hash[1] = 0; int pos = 2; while(pos < hash.size()){ while(p原创 2021-04-14 20:43:03 · 52 阅读 · 0 评论 -
C++ 双向链表实现
#include <utility> #include <iterator> using namespace std; template<class T> class DLinkedListIterator : public iterator<input_iterator_tag, T>{ public: DLinkedListIterator(T* p){_ptr = p;} T& operator * (){return *_ptr;}原创 2021-04-08 21:29:29 · 49 阅读 · 0 评论 -
C++中 istringstream 实现字符串按空格分割
deque<string> Strs; string s; istringstream IN(sentence); while(IN >> s){ Strs.push_back(IN); }原创 2021-04-06 19:18:27 · 501 阅读 · 0 评论