- 博客(9)
- 收藏
- 关注
原创 观察者模式
#include<iostream> #include<list> #include<string> using namespace std; class Subject; class Observer { public: Observer() {} virtual ~Observer() {} virtual void update(Subject* subject) = 0; virtual void update(string content) = .
2020-11-16 20:30:57 176
原创 C/C++编程题刷题:质数对的个数
#include<iostream> using namespace std; bool isPrime(int n) { for (int i = 2; i < n; i++) { if (n%i == 0) return false; } return true; } int main() { int n; cin >> n; int cnt = 0; for (int i = 2; i < n; i++) { if (isPrime(i.
2020-11-07 00:16:54 351
原创 C/C++编程题刷题:多线程交替打印ABC
#include<thread> #include<iostream> #include<mutex> #include<vector> #include<condition_variable> using namespace std; mutex mtx; condition_variable cond; char s[] = { 'A','B','C' }; char message = 'A'; void handler(int i) .
2020-11-07 00:15:34 457
原创 Mymemmove_memcpy类
#include<iostream> using namespace std; void* mymemcpy(void *dst, const void *src, size_t size) { if (dst == NULL || src == NULL) return NULL; char* psrc; char* pdst; psrc = (char*)src; pdst = (char*)dst; while (size--) { *pdst++ = *psrc+..
2020-11-07 00:08:28 134
原创 MyStringcopy类
#include<iostream> #include<assert.h> using namespace std; int mystrlen(const char* src) { assert(src != NULL); const char* head = src; while (*src != '\0') src++; return (src - head - 1); } char * mystrcopy(char * src, char* dst) { if ..
2020-11-07 00:07:23 124
原创 MyString类
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<string> using namespace std; class MyString { public: MyString(); MyString(const char* const p); MyString(const MyString & s); ~MyString(); MyString& operator = (const ..
2020-11-07 00:05:48 280
原创 栈
#include<iostream> using namespace std; class MyStack { public: MyStack(int cap) { capacity = cap; Bottom = 0; Top = 0; size = 0; pStack = new int[capacity]; } MyStack() { capacity = 5; Bottom = 0; Top = 0; size = 0; pStack =.
2020-11-07 00:04:25 75
原创 循环队列
#include<iostream> using namespace std; class cycleQueue { private: int *cycleQueueHead; int front; int rear; int size; void resize() { int *temp = new int[size * 2]; int j = 0; for (int i = front; i != rear; i = (i + 1) % size) { tem.
2020-11-07 00:03:37 97
原创 C/C++编程题刷题:topK快排和堆排序的解决方案
#include<iostream> #include<vector> #include<deque> using namespace std; #define random(x) (rand()%x) bool isAsc = false; //堆调整 void HeapAdjust(vector<int> &nums, int index, int n) { int leftChild = 2 * index + 1; int righC.
2020-11-06 20:35:24 214
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人