64,654
社区成员
发帖
与我相关
我的任务
分享
ListNode node(i);
if (i == 0) {
t.push_back(node);
}
// Win32Project3.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :val(x) {};
ListNode() {}
};
void test() {
vector<ListNode> t;
t.resize(200);
for (int i = 0; i < 100; i++){
ListNode node(i);
if (i > 0) {
node.next = &t.back();
}
t.push_back(node);
if (i > 0) {
cout << node.val << "\t" << node.next->val << endl;
}
}
}
int main() {
test();
getchar();
}