上一页 1 2 3 4 5 6 7 8 9 10 ··· 17 下一页
摘要: 题目 自己写的 class Solution { public: bool validMountainArray(vector<int>& arr) { int l = 0, r = 1; bool up = true, change = false; if (arr.size() < 3) ret 阅读全文
posted @ 2024-11-17 19:25 hisun9 阅读(11) 评论(0) 推荐(0)
摘要: 题目 初看感觉蛮简单,但是实现过程中就犯迷糊了,主要是针对重复的元素不知道咋简单的写代码处理得到小于该重复数字的个数,然后看了卡哥的讲解,给了很好的思路: 这个思路和y总讲 01背包问题 的时候对二维dp优化为一维dp的思路大相径庭,很奇妙! 给出自己在看了卡哥思路后尝试写的代码: class So 阅读全文
posted @ 2024-11-17 18:50 hisun9 阅读(13) 评论(0) 推荐(0)
摘要: QObject QObject 的角色和特点 在 Qt 框架中,QObject 是整个对象模型的核心基类,它为 Qt 对象树 和 信号-槽机制 提供了基础支持。很多 Qt 的类(包括 QWidget、QDialog、QMainWindow)都直接或间接继承自 QObject。 QObject 的核心 阅读全文
posted @ 2024-11-17 14:10 hisun9 阅读(368) 评论(0) 推荐(0)
摘要: 看这样一段代码: #include <iostream> using namespace std; int main() { const char s[] = "hello"; cout << "Array content (s): " << s << endl; // 输出字符串内容 cout < 阅读全文
posted @ 2024-11-17 00:55 hisun9 阅读(48) 评论(0) 推荐(0)
摘要: 5.1 节练习 练习 5.1 空语句是最简单的语句,空语句由一个单独的分号构成。如果在程序的某个地方,语法上需要一条语句但是逻辑上不需要,此时应该使用空语句,空语句什么也不做。 一种常见的情况是,当循环的全部工作在条件部分就可以完成时,我们通常会用到空语句。使用空语句时最好加上注释,从而令代码的阅读 阅读全文
posted @ 2024-11-17 00:21 hisun9 阅读(27) 评论(0) 推荐(0)
摘要: 题目 自己尝试了好几次,才通过了 class Solution { public: vector<int> spiralOrder(vector<vector<int>>& matrix) { vector<int> ans; if (array.empty()) return ans; int x 阅读全文
posted @ 2024-11-16 20:07 hisun9 阅读(17) 评论(0) 推荐(0)
摘要: 问题 在写程序的时候遇到了这样一个问题,见代码 #include <iostream> #include <vector> using namespace std; bool isequal(vector<int> vshort, vector<int> vlong) { for (int inde 阅读全文
posted @ 2024-11-16 15:57 hisun9 阅读(26) 评论(0) 推荐(0)
摘要: std::stringstream 是 C++ 标准库中提供的一个类,定义在头文件 <sstream> 中。它是基于字符串的流(stream),允许像操作输入流(std::cin)或输出流(std::cout)那样,操作字符串内容。 std::stringstream 是 std::iostream 阅读全文
posted @ 2024-11-16 15:52 hisun9 阅读(314) 评论(0) 推荐(0)
摘要: 在 C++ 中,itoa 和 sprintf 是用于将数值转换为字符串的经典函数。然而,它们有一定的局限性或者安全性问题,现代 C++ 更倾向于使用标准库的解决方案,如 std::to_string 和 std::stringstream,来代替这些函数。 可以看看这篇博客 streamstring 阅读全文
posted @ 2024-11-16 15:48 hisun9 阅读(146) 评论(0) 推荐(0)
摘要: stoi 是 C++ 标准库中的一个函数,定义在头文件 <string> 中,它用于将字符串转换为整数类型。 函数原型 int stoi(const std::string& str, size_t* idx = 0, int base = 10); str(必选):要转换的字符串,必须以数字开头( 阅读全文
posted @ 2024-11-16 14:23 hisun9 阅读(1480) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 17 下一页