add
This commit is contained in:
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@@ -6,7 +6,8 @@
|
|||||||
"${workspaceFolder}/**"
|
"${workspaceFolder}/**"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"defines": [],
|
||||||
"intelliSenseMode": "linux-gcc-x64"
|
"intelliSenseMode": "linux-gcc-x64",
|
||||||
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.0)
|
cmake_minimum_required(VERSION 3.6)
|
||||||
project(lc VERSION 0.1.0)
|
project(lc VERSION 0.1.0)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|||||||
40
main.cpp
40
main.cpp
@@ -6,42 +6,8 @@
|
|||||||
* @LastEditTime: 2022-11-21 21:08:42
|
* @LastEditTime: 2022-11-21 21:08:42
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
int main() {
|
||||||
|
std::cout << "hello" << std::endl;
|
||||||
struct ListNode {
|
return 0;
|
||||||
int val;
|
|
||||||
ListNode* next;
|
|
||||||
// ListNode(int x) : val(x), next(NULL) {} //
|
|
||||||
ListNode(int x, ListNode* n = NULL) : val(x), next(n) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Solution {
|
|
||||||
public:
|
|
||||||
vector<int> reversePrint(ListNode* head) {
|
|
||||||
reverse(head);
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
vector<int> result;
|
|
||||||
void reverse(ListNode* head) {
|
|
||||||
if (head != nullptr) {
|
|
||||||
if (head->next != nullptr) {
|
|
||||||
reversePrint(head->next);
|
|
||||||
}
|
|
||||||
result.push_back(head->val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int, char**) {
|
|
||||||
|
|
||||||
// ListNode* head = new ListNode(1);
|
|
||||||
// head -> next = new ListNode(3);
|
|
||||||
// head -> next -> next = new ListNode(2);
|
|
||||||
|
|
||||||
Solution s;
|
|
||||||
std::cout << s.reversePrint(head)[0] << s.reversePrint(head)[1] << s.reversePrint(head)[2] << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user