摘要: #include <bits/stdc++.h> using namespace std; class Count { private: int cnt; public: Count() :cnt(1) {} ~Count() = default; void addcount() { ++cnt; 阅读全文
posted @ 2023-09-15 21:49 SuperTonyy 阅读(142) 评论(0) 推荐(0)
摘要: //冒泡排序,一句话概括:从前往后遍历,如果a[j-1] > a[j],则交换位置,将最大值放到最后。 void bubble_sort(vector<int>& nums, int n) { if (n <= 1) return; bool flag = false; for (int i = 1 阅读全文
posted @ 2023-09-13 16:42 SuperTonyy 阅读(9) 评论(0) 推荐(0)
摘要: //快速排序,递归操作,先找到枢纽,将所有比枢纽小的数放到其左边,将所有比其大的数放到其右边 void QuickSort(vector<int>& nums, int l, int r){ if (l + 1 >= r) return; int x = l, y = r - 1, xnum = n 阅读全文
posted @ 2023-09-13 16:36 SuperTonyy 阅读(10) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; struct TreeNode { int val; struct TreeNode* left; struct TreeNode* right; TreeNode(int val) :val(val), l 阅读全文
posted @ 2023-09-13 16:35 SuperTonyy 阅读(12) 评论(0) 推荐(0)
摘要: class Lazy_Singleton { private: Lazy_Singleton() {}; ~Lazy_Singleton() {}; Lazy_Singleton(const Lazy_Singleton&) {}; Lazy_Singleton& operator = (const 阅读全文
posted @ 2023-09-08 13:01 SuperTonyy 阅读(9) 评论(0) 推荐(0)
摘要: 1.简单工厂模式 #include <bits/stdc++.h> using namespace std; class produce { private: int width; int height; public: produce(int width,int height):width(wid 阅读全文
posted @ 2023-09-07 20:52 SuperTonyy 阅读(49) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; class String { public: String(const char* str = NULL){// 普通构造函数 cout << "普通构造函数被调用" << endl; if (str == 阅读全文
posted @ 2023-09-07 15:56 SuperTonyy 阅读(66) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; class animal { public: // 纯虚函数 // virtual void sound() = 0; // 虚函数 virtual void sound() { cout << "anima 阅读全文
posted @ 2023-09-07 15:06 SuperTonyy 阅读(18) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; class student { private: char* name; public: student() { name = new char(20); cout << "创建student" << end 阅读全文
posted @ 2023-09-07 14:00 SuperTonyy 阅读(14) 评论(0) 推荐(0)
摘要: 第一题,实现链表翻转 第二题,实现链表指定区域翻转 #include <bits/stdc++.h> using namespace std; struct ListNode { int val; struct ListNode* next; ListNode(int x) : val(x), ne 阅读全文
posted @ 2023-09-05 19:47 SuperTonyy 阅读(17) 评论(0) 推荐(0)