摘要: 在C++中,std::map容器内存放的是数据本身(即键值对的值部分),而不是数据地址。当我们插入一个键值对时,std::map会自动复制值并存储副本 void test02() { multimap<int, Worker> m; Worker w; w.name = "sd"; w.salary 阅读全文
posted @ 2023-11-28 21:51 晚生小白 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 错误示范: //测试如何获取multimap内key为i的所有value /* * multimap容器的find()函数返回一个迭代器,此迭代器引用 multimap 当中具有与指定键等效的键的元素的第一个位置。 * 而且mutimap容器中的数据是根据key值自动排序了的。 */ void ge 阅读全文
posted @ 2023-11-28 21:29 晚生小白 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 错误示范: int* test01() { int data[3] = { 1,2,3 }; return data; } int main() { int* result = test01(); for (int i = 0; i < 3; i++) { cout << result[i] << 阅读全文
posted @ 2023-11-06 17:22 晚生小白 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 正确示范: void change(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } 错误示范: void change(int* a, int* b) { int* temp = a; a = b; b = temp; } 阅读全文
posted @ 2023-07-26 11:30 晚生小白 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 方法一:直接for循环 时间复杂度为O(n2) 优点:简单 缺点:效率太低 public static int maxArea1(int[]height){ int max=0; int area=0; for (int i=0;i<height.length-1;i++){ for (int j= 阅读全文
posted @ 2022-09-13 10:25 晚生小白 阅读(34) 评论(0) 推荐(0) 编辑
摘要: public int reverse(int x){ int size=0; int result=0; boolean boo=true; if (x==0){ return 0; } int temp=x; while (temp!=0){ temp/=10; // 注意:这个判断不能在whil 阅读全文
posted @ 2022-09-05 22:07 晚生小白 阅读(169) 评论(0) 推荐(0) 编辑
摘要: package myStack; //栈异常:自定义栈 public class StackException extends Exception{ public StackException(){ } public StackException(String s){ super(s); } } p 阅读全文
posted @ 2022-07-22 21:49 晚生小白 阅读(34) 评论(0) 推荐(0) 编辑
摘要: import java.util.Random; /*产生5个0~100的不同的随机数,若相同则重新生成 * 将生成的5个随机数放到数组中*/ public class RandomTest02 { public static void main(String[] args) { Random r1 阅读全文
posted @ 2022-07-03 01:09 晚生小白 阅读(224) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示