This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 定义通信报文类型 */ | |
struct car_frame{ | |
short int head; //报文头 | |
short int identification; //报文标识 | |
/* 手机APP */ | |
short int Left; //左转 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************ | |
* 功能:上行报文解析(仅作测试,发送APP) | |
* 注意:仅选择其中个ID作为测试 | |
************************************************************/ | |
struct down_APPframe frame_up_app_process(struct can_frame r_frame){ | |
struct down_APPframe r_send_frame; | |
//------------------------------------------------------------------- | |
//ID:0x518 | |
//------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Box { | |
private: | |
double length; | |
double breadth; | |
double height; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
class Test { | |
int i; | |
public: | |
Test(int i) { | |
cout << "Test(int i)" << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//思路:累积和(prefix_sum) | |
//时间:8 ms | |
class Solution { | |
public: | |
int maxSubArray(vector<int>& nums) { | |
if (nums.size() < 0) return 0; | |
int prefix_sum = 0; | |
int min_sum = 0; | |
int result = INT_MIN; | |
for (auto n : nums) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
bool isValid(string s) { | |
vector<char> stack; | |
stack.push_back(' '); | |
for(int i = 0;i < s.size();i++){ | |
char item = s[i]; | |
if(item == '(' || item == '[' || item == '{'){ | |
stack.push_back(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int removeDuplicates(vector<int>& nums) { | |
if(nums.empty()) | |
return 0; | |
int len = 0; | |
for(int i = 1;i < nums.size();++i){ | |
if(nums[i] != nums[len]) | |
nums[++len] = nums[i]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int removeElement(vector<int>& nums, int val) { | |
if(nums.empty()) return 0; | |
int len = 0; | |
for(int i = 0;i < nums.size();++i){ | |
if(nums[i] != val) | |
nums[len++] = nums[i]; | |
} | |
return len; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
vector<int> plusOne(vector<int>& digits) { | |
int len = digits.size(); | |
vector<int> array = digits; | |
array[len - 1] += 1; | |
for(int i = len - 1;i > 0;i--){ | |
if(array[i] >= 10){ | |
array[i] = array[i] % 10; | |
array[i - 1] += 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//思路:第一次尝试,使用了额外空间来对数组元素进行计数 | |
//时间:104 ms | |
class Solution { | |
public: | |
vector<int> findDuplicates(vector<int>& nums) { | |
vector<int> array = nums; | |
vector<int> find_array; | |
array.push_back(0); | |
for(int i = 0;i < array.size();++i) |
OlderNewer