01 2020 档案
C++函数传递类对象和类对象的引用
摘要:1 #include <iostream> 2 #include<string> 3 using namespace std; 4 5 class Point { 6 public: 7 Point(int a, int b) :x(a), y(b) {}; 8 //Point(Point& p) 阅读全文
posted @ 2020-01-05 16:34 Chenjin123 阅读(3079) 评论(0) 推荐(0)
C++三种继承方式
摘要:public: 公有继承时,对基类的公有成员和保护成员的访问属性不变,派生类的新增成员可以访问基类的公有成员和保护成员,但是访问不了基类的私有成员。派生类的对象只能访问派生类的公有成员(包括继承的公有成员),访问不了保护成员和私有成员。 protected: 保护继承中,基类的公有成员和保护成员被派 阅读全文
posted @ 2020-01-05 14:01 Chenjin123 阅读(2074) 评论(0) 推荐(1)
1200. 最小绝对差(排序)
摘要:思路: 1.先对数组排序 2.遍历第一遍求最小绝对值差 3.遍历第二遍填充最小绝对值差的元素对 1 class Solution { 2 public List<List<Integer>> minimumAbsDifference(int[] arr) { 3 int minAbs=Integer 阅读全文
posted @ 2020-01-03 19:45 Chenjin123 阅读(309) 评论(0) 推荐(0)
1218. 最长定差子序列(动态规划)
摘要:题意:从给定数组中提取出最长的等差序列(不一定连续),返回它的长度 暴力超时: 1 class Solution { 2 public int longestSubsequence(int[] arr, int difference) { 3 int res=1; 4 for(int i=0;i<a 阅读全文
posted @ 2020-01-03 19:32 Chenjin123 阅读(307) 评论(0) 推荐(0)