上一页 1 2 3 4 5 6 ··· 10 下一页
摘要: 当返回多个参数时,可以使用tuple、pair,它们都是使用get<0...n>(name)取值 结构体绑定;就是将返回的参数自定义名字,要用"[]"括起来。 std::pair<std::string, int>CreatePerson(){ return { "Kxin",22 }; } aut 阅读全文
posted @ 2023-10-23 16:53 iu本u 阅读(18) 评论(0) 推荐(0)
摘要: 本题有两种思路: 在s中找到t的开头字母,假设s[1]==t[0],那么dp(s,1,t,0)就等于dp(s,2,t,1); 假设在s中找到s[i]==t[j],那么将会有两种情况:1.就让i位置和j匹配:dp(s,i+1,t,j+1)2.不让i位置和j匹配:dp(s,i+1,t,j); 如果i和j 阅读全文
posted @ 2023-10-23 13:08 iu本u 阅读(10) 评论(0) 推荐(0)
摘要: 纸牌问题的解决办法: int piles=0; for(int i=0;i<nums.size();i++){ int poker=nums[i]; int left=0;int right=piles; while(left<right){ int mid=(left+right)/2; if(t 阅读全文
posted @ 2023-10-19 12:59 iu本u 阅读(18) 评论(0) 推荐(0)
摘要: class Timer { private: std::chrono::time_point<std::chrono::high_resolution_clock>m_StartTimepoint; public: Timer() { m_StartTimepoint = std::chrono:: 阅读全文
posted @ 2023-10-18 21:03 iu本u 阅读(35) 评论(0) 推荐(0)
摘要: 都在运行时执行,而不是在编译时执行,所以有运行成本。它们实际是函数,所以需要传参数,还有返回值。 \static_cast: c++中传统的类型转换直接使用(类型),如果出错也不会提醒错误,但使用static_cast<类型>就会提示 reinterpret_cast: 类型相关的转换,起始是底层内 阅读全文
posted @ 2023-10-16 20:54 iu本u 阅读(37) 评论(0) 推荐(0)
摘要: 右击断点-》选择Conditions/Actions-》增加触发条件(使用{}符号括起要在console上打印的变量) 这样有助于节省时间,可以在运行程序的同时不中断调试代码。 阅读全文
posted @ 2023-10-10 20:54 iu本u 阅读(32) 评论(0) 推荐(0)
摘要: 一般标记了virtual的关键字就是虚函数,虚函数就代表这个函数之后要进行重写; 虚函数增加virtual之后是将会将子类的函数扩展添加进去,而不是重写。 class Base { public: Base() { std::cout << " Base Constructor \n"; } vir 阅读全文
posted @ 2023-10-08 20:03 iu本u 阅读(30) 评论(0) 推荐(0)
摘要: 联合体只有一个成员,所以可以在一个联合体用不同的方式定义一个成员 这一个成员站得内存都是一个内存 联合体可以是匿名的也可以是有名字的 struct Vector2{ float x, y; }; struct Vector4 { union { struct { float x, y, z, w; 阅读全文
posted @ 2023-10-08 19:14 iu本u 阅读(20) 评论(0) 推荐(0)
摘要: std::sort(vector.begin(),vector.end(),[](int a,int b){ if(a==1)return false;//a为1就将这个1排在最后,因为返回的是false if(b==1)return true;//还是将1排在最后 return a>b;//降序排 阅读全文
posted @ 2023-10-07 13:56 iu本u 阅读(105) 评论(0) 推荐(0)
摘要: 创建Thread:std::thread worker(操作); 打印当前线程的id:std::this_thread::get_id(); is_finished=false; DoWork(){ using namespace std::literals::chrono_literals; st 阅读全文
posted @ 2023-09-26 19:23 iu本u 阅读(81) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 10 下一页