摘要:
动态规划中优化枚举 1235. 规划兼职工作 #include <iostream> #include <vector> #include <algorithm> using namespace std; class Solution { public: int jobScheduling(vect 阅读全文
posted @ 2025-05-14 23:07
n1ce2cv
阅读(3)
评论(0)
推荐(1)
摘要:
const关键字 1. 常量变量 当 const 用于普通变量时,它表示该变量的值在初始化后不能被修改。 const int x = 10; x = 20; // 错误,不能修改常量变量 2. 常量成员函数 当 const 用于成员函数时,表示该函数不会修改对象的状态。通常用于 getter 函数。 阅读全文
posted @ 2025-05-14 18:42
n1ce2cv
阅读(4)
评论(0)
推荐(0)
摘要:
左值右值 1. 概念 概念 简明解释 左值(lvalue) 有名字、有地址的对象,能出现在赋值号左边 右值(rvalue) 没有名字、临时存在的值,只能出现在赋值号右边 举例: int a = 10; int b = a + 5; 表达式 类型 说明 a 左值 有名字,可以 &a 取地址 10 右值 阅读全文
posted @ 2025-05-14 18:41
n1ce2cv
阅读(18)
评论(0)
推荐(0)
摘要:
引用的使用场景 1. 函数参数传递(避免拷贝,提高效率) 当函数参数是一个大型对象(如结构体、vector、string),如果传值会产生拷贝,浪费性能: void modify(string &s) { // 用引用传递,避免拷贝 s += " modified"; } 如果用: void mod 阅读全文
posted @ 2025-05-14 01:37
n1ce2cv
阅读(6)
评论(0)
推荐(0)