int main(int argc, char const *argv[]) { ListNode n1(5); ListNode n2(10); ListNode n3(2); ListNode n4(3); n1.next = &n2; n2.next = &n3; n3.next = &n4; solve(&n1); ListNode* itr = &n1; while(itr) { std::cout << "At node with value " << itr->data << std::endl; std::cout << "Biggest in right: "; if(itr->arbitrary) std::cout << itr->arbitrary->data; else std::cout << "NULL"; std::cout << std::endl << std::endl; itr = itr->next; } return 0; }
int main(int argc, char* argv[]) { Solution s; ListNode n1(1); ListNode n3(3); ListNode n5(5); ListNode n2(2); ListNode n4(4); ListNode n6(6); n1.next = &n3; n3.next = &n5; n2.next = &n4; n4.next = &n6; ListNode *ret1 = s.mergeTwoLists(&n1, &n2); int i = 0; while (ret1 != NULL) { i++; assert(ret1->val == i); ret1 = ret1->next; } i = 2; ret1 = s.mergeTwoLists(&n1, NULL); while (ret1 == NULL) { assert(ret1->val == 2); i += 2; ret1 = ret1->next; } return 0; }
int main() { TreeNode n1(5); TreeNode n2(4); TreeNode n3(8); TreeNode n4(11); TreeNode n5(13); TreeNode n6(4); TreeNode n7(7); TreeNode n8(2); TreeNode n9(1); n1.left = &n2; n1.right = &n3; n2.left = &n4; n4.left = &n7; n4.right = &n8; n3.left = &n5; n3.right = &n6; n6.right = &n9; Solution sln; cout << sln.hasPathSum(&n1, 22) << endl; return 0; }
int main(int argc, char const *argv[]) { // 0 // / \ // 1 2 // / \ \ // 3 4 7 // \ / // 5 8 // \ // 6 TreeNode<int> n0(0); TreeNode<int> n1(1); TreeNode<int> n2(2); TreeNode<int> n3(3); TreeNode<int> n4(4); TreeNode<int> n5(5); TreeNode<int> n6(6); TreeNode<int> n7(7); TreeNode<int> n8(8); n0.left = &n1; n0.right = &n2; n1.left = &n3; n1.right = &n4; n4.right = &n5; n5.right = &n6; n2.right = &n7; n7.left = &n8; bool* matrix = solve(&n0); delete[] matrix; return 0; }
main() { P1DIR = 0xFF; while(1) { n1(); delay(65000); n2(); delay(65000); n3(); delay(65000); n4(); delay(65000); n5(); delay(65000); n6(); delay(65000); n7(); delay(65000); n8(); delay(65000); n9(); delay(65000); n0(); delay(65000); } }
main(int argc, char *argv[]) { node gnd; node n1("n1"); node n2("n2"); node n3("n3"); node n4("n4"); node n5("n5"); node n6("n6"); vdc vcc("vcc", n6, gnd, 5.0); vpulse vin("vin", n1, gnd, 0, 5, 2e-9, 2e-9, 2e-9, 10e-9); r rb1("rb1", n1, n2, 10e3); r rc1("rc1", n6, n3, 1e3); qnd q1("q1", n3, n2, gnd); r rb2("rb2", n3, n4, 10e3); qnd q2("q2", n5, n4, gnd); r rc2("rc2", n6, n5, 1e3); op::monitor = 1; op(); plot::output = *argv; plot::add("n1", "n3", "n5"); tran::tsmin = 1.0e-30; tran::monitor = 1; tran(0.2e-9, 20.0e-9); }
int main(){ Node head1(3); Node n1(2); Node n2(1); Node n3(5); Node n4(6); head1.Left=&n1; head1.Right=&n3; n1.Left=&n2; n3.Right=&n4; Node head2(9); Node n1b(8); Node n2b(2); Node n3b(10); Node n4b(11); head2.Left=&n1b; head2.Right=&n3b; n1b.Left=&n2b; n3b.Right=&n4b; std::cout << " the median of the two arrays is : " << std::setprecision( 2 )<< arrayMedian(&head1,&head2)<<std::endl; return 0; }
void TestSortList() { SortList::ListNode node4(1); SortList::ListNode node3(2); node3.next = &node4; SortList::ListNode node2(3); node2.next = &node3; SortList::ListNode node1(4); node1.next = &node2; SortList::SolutionSortList so; SortList::ListNode *newhead = so.sortList(&node1); node4.next = &node2; node2.next = &node3; node3.next = nullptr; newhead = so.sortList(&node4);//1,3,2 SortList::ListNode n1(1); SortList::ListNode n2(2); n2.next = &n1; SortList::ListNode n3(3); n3.next = &n2; SortList::ListNode n4(4); n4.next = &n3; SortList::ListNode n5(5); n5.next = &n4; newhead = so.sortList(&n5); }
JSONNode ModuleManager::convertIrcChannelToJSONString(IrcChannel& channel) { JSONNode n(JSON_NODE); n.push_back(JSONNode("name", channel.name)); n.push_back(JSONNode("topic", channel.topic)); n.push_back(JSONNode("nameListFull", channel.nameListFull)); JSONNode n2(JSON_ARRAY); n2.set_name("members"); std::vector<IrcChannelMember>::iterator iter; for(iter=channel.members.begin(); iter!=channel.members.end(); ++iter) { JSONNode n3(JSON_NODE); n3.push_back(JSONNode("nick", (*iter).nick)); JSONNode n4(JSON_ARRAY); n4.set_name("modes"); for(std::uint64_t i=1; i!=std::uint64_t(1) << 52; i<<=1) { bool current_bit = ((*iter).modes & i) != 0; n4.push_back(JSONNode("flag", current_bit)); } n3.push_back(n4); n2.push_back(n3); } n.push_back(n2); return n; }
TEST(removeNthFromEnd, caseTest) { Solution s; ListNode n0(0); EXPECT_EQ(NULL, s.removeNthFromEnd(&n0, 1)); ListNode n1(1); ListNode n2(2); n1.next = &n2; ListNode* n3 = s.removeNthFromEnd(&n1, 2); EXPECT_EQ(&n2, n3); EXPECT_EQ(NULL, n3->next); ListNode n4(4); ListNode n5(5); ListNode n6(6); ListNode n7(7); n4.next = &n5; n5.next = &n6; n6.next = &n7; ListNode *n8 = s.removeNthFromEnd(&n4, 4); EXPECT_EQ(5, n8->val); EXPECT_EQ(6, n8->next->val); }
int main() { typedef node<int> node_t; // Construction node_t n1( 1, 1 ); node_t n2( 2, 1 ); node_t n3( 2, 2 ); node_t n4( 3, 3 ); // Stream insertion std::ostringstream oss; oss << n1 << ' ' << n2 << ' ' << n3 << ' ' << n4; run_test( oss.str() == "(1,1) (2,1) (2,2) (3,3)" ); // Predicates run_test( node_t::ascending( n1, n1 ) ); run_test( node_t::descending( n1, n1 ) ); run_test( !node_t::strict_ascending( n1, n1 ) ); run_test( !node_t::strict_descending( n1, n1 ) ); run_test( node_t::ascending( n1, n3 ) ); run_test( !node_t::descending( n1, n3 ) ); run_test( node_t::strict_ascending( n1, n3 ) ); run_test( !node_t::strict_descending( n1, n3 ) ); run_test( node_t::ascending( n2, n3 ) ); run_test( !node_t::descending( n2, n3 ) ); run_test( node_t::strict_ascending( n2, n3 ) ); run_test( !node_t::strict_descending( n2, n3 ) ); run_test( node_t::ascending( n1, n2 ) ); run_test( node_t::descending( n1, n2 ) ); run_test( !node_t::strict_ascending( n1, n2 ) ); run_test( !node_t::strict_descending( n1, n2 ) ); run_test( !node_t::ascending( n4, n2 ) ); run_test( node_t::descending( n4, n2 ) ); run_test( !node_t::strict_ascending( n4, n2 ) ); run_test( node_t::strict_descending( n4, n2 ) ); run_test( node_t::left_turn( n1, n2, n3 ) ); run_test( !node_t::right_turn( n1, n2, n3 ) ); run_test( node_t::strict_left_turn( n1, n2, n3 ) ); run_test( !node_t::strict_right_turn( n1, n2, n3 ) ); run_test( !node_t::left_turn( n1, n3, n2 ) ); run_test( node_t::right_turn( n1, n3, n2 ) ); run_test( !node_t::strict_left_turn( n1, n3, n2 ) ); run_test( node_t::strict_right_turn( n1, n3, n2 ) ); run_test( node_t::left_turn( n1, n3, n4 ) ); run_test( node_t::right_turn( n1, n3, n4 ) ); run_test( !node_t::strict_left_turn( n1, n3, n4 ) ); run_test( !node_t::strict_right_turn( n1, n3, n4 ) ); }
int main(){ node n1(1); node n2(2); node n3(3); node n4(4); node n5(5); node n6(6); node n7(7); node n8(8); node n9(9); node n10(10);
void MyMoneyPriceTest::testValidity() { QString emptyId; MyMoneyPrice n1(emptyId, QString("to"), QDate(2005, 9, 23), MyMoneyMoney(1, 3), QString("MySource")); MyMoneyPrice n2(QString("from"), emptyId, QDate(2005, 9, 23), MyMoneyMoney(1, 3), QString("MySource")); MyMoneyPrice n3(QString("from"), QString("to"), QDate(), MyMoneyMoney(1, 3), QString("MySource")); MyMoneyPrice n4(QString("from"), QString("to"), QDate(2005, 9, 23), MyMoneyMoney(1, 3), QString("MySource")); QVERIFY(n1.isValid() == false); QVERIFY(n2.isValid() == false); QVERIFY(n3.isValid() == false); QVERIFY(n4.isValid() == true); }
/** * 円柱を構築する。(カラー版) * 側面のみ。上面と底面はなし。 */ void VBORenderManager::addCylinder(const QString& geoName, const glm::mat4& modelMat, float baseRadius, float topRadius, float height, const QColor& color, int slices, int stacks) { std::vector<Vertex> verts; for (int i = 0; i < stacks; ++i) { float z1 = height / stacks * i; float z2 = height / stacks * (i + 1); float radius1 = (topRadius - baseRadius) / stacks * i + baseRadius; float radius2 = (topRadius - baseRadius) / stacks * (i + 1) + baseRadius; for (int j = 0; j < slices; ++j) { float theta1 = 2.0 * M_PI * j / slices; float theta2 = 2.0 * M_PI * (j + 1) / slices; float x1 = radius1 * cosf(theta1); float y1 = radius1 * sinf(theta1); float x2 = radius1 * cosf(theta2); float y2 = radius1 * sinf(theta2); float x3 = radius2 * cosf(theta2); float y3 = radius2 * sinf(theta2); float x4 = radius2 * cosf(theta1); float y4 = radius2 * sinf(theta1); glm::vec4 p1(x1, y1, z1, 1.0f); glm::vec4 p2(x2, y2, z1, 1.0f); glm::vec4 p3(x3, y3, z2, 1.0f); glm::vec4 p4(x4, y4, z2, 1.0f); p1 = modelMat * p1; p2 = modelMat * p2; p3 = modelMat * p3; p4 = modelMat * p4; glm::vec4 n1(x1, y1, sqrtf(x1*x1+y1*y1) / height * (baseRadius - topRadius), 0.0f); glm::vec4 n2(x2, y2, sqrtf(x2*x2+y2*y2) / height * (baseRadius - topRadius), 0.0f); glm::vec4 n3(x3, y3, sqrtf(x3*x3+y3*y3) / height * (baseRadius - topRadius), 0.0f); glm::vec4 n4(x4, y4, sqrtf(x4*x4+y4*y4) / height * (baseRadius - topRadius), 0.0f); n1 = modelMat * n1; n2 = modelMat * n2; n3 = modelMat * n3; n4 = modelMat * n4; verts.push_back(Vertex(glm::vec3(p1), color, glm::vec3(n1), glm::vec3())); verts.push_back(Vertex(glm::vec3(p2), color, glm::vec3(n2), glm::vec3())); verts.push_back(Vertex(glm::vec3(p3), color, glm::vec3(n3), glm::vec3())); verts.push_back(Vertex(glm::vec3(p1), color, glm::vec3(n1), glm::vec3())); verts.push_back(Vertex(glm::vec3(p3), color, glm::vec3(n3), glm::vec3())); verts.push_back(Vertex(glm::vec3(p4), color, glm::vec3(n4), glm::vec3())); } } addStaticGeometry(geoName, verts, "", GL_TRIANGLES, 1|mode_Lighting); }
int main(){ TreeNode n0(10); TreeNode n1(5); TreeNode n2(15); TreeNode n3(6); TreeNode n4(20); n0.left = &n1; n0.right = &n2; n2.left = &n3; n2.right = &n4; bool res = isValidBST(&n0); printf("%s\n", res?"true":"false"); return 0; }
void runEmptyRelationNoMemberCountTagTest() { //add some nodes to a map OsmMapPtr map(new OsmMap()); ElementPtr n1(new Node(Status::Unknown1, 1, 0, 0, 0)); ElementPtr n2(new Node(Status::Unknown2, 2, 0, 0, 0)); ElementPtr n3(new Node(Status::Unknown1, 3, 0, 0, 0)); ElementPtr n4(new Node(Status::Unknown2, 4, 0, 0, 0)); map->addElement(n1); map->addElement(n2); map->addElement(n3); map->addElement(n4); //create two reviews involving the two pairs of nodes ReviewMarker reviewMarker; reviewMarker.mark(map, n1, n2, "note 1", "test 1"); reviewMarker.mark(map, n3, n4, "note 2", "test 2"); CPPUNIT_ASSERT_EQUAL((size_t)2, map->getRelations().size()); CPPUNIT_ASSERT(reviewMarker.isNeedsReview(map, n1, n2)); CPPUNIT_ASSERT(reviewMarker.isNeedsReview(map, n3, n4)); //get the review relations set<ElementId> review1 = reviewMarker._getReviewRelations(map, n1->getElementId()); CPPUNIT_ASSERT_EQUAL((size_t)1, review1.size()); const ElementId r1Id = *review1.begin()++; set<ElementId> review2 = reviewMarker._getReviewRelations(map, n3->getElementId()); CPPUNIT_ASSERT_EQUAL((size_t)1, review2.size()); const ElementId r2Id = *review2.begin()++; RelationPtr relation1 = map->getRelation(r1Id.getId()); RelationPtr relation2 = map->getRelation(r2Id.getId()); //go ahead and remove their review member count tags relation1->getTags().remove(MetadataTags::HootReviewMembers()); relation2->getTags().remove(MetadataTags::HootReviewMembers()); //remove all of one of the review relation's members RemoveElementOp::removeElement(map, n3->getElementId()); RemoveElementOp::removeElement(map, n4->getElementId()); relation2->removeElement(n3->getElementId()); relation2->removeElement(n4->getElementId()); //run the visitor RemoveInvalidReviewRelationsVisitor v; map->visitRw(v); //the empty review relation should have been removed CPPUNIT_ASSERT_EQUAL((size_t)1, map->getRelations().size()); CPPUNIT_ASSERT(map->containsElement(r1Id)); CPPUNIT_ASSERT(!map->containsElement(r2Id)); }
int main() { // init data TreeNode n6(6); TreeNode n2(2); TreeNode n8(8); TreeNode n0(0); TreeNode n4(4); TreeNode n7(7); TreeNode n9(9); TreeNode n3(3); TreeNode n5(5); n6.left = &n2; n6.right = &n8; n2.left = &n0; n2.right = &n4; n8.left = &n7; n8.right = &n9; n4.left = &n3; n4.right = &n5; // 测试 fillMapParents Solution sol; map<TreeNode*, TreeNode*> mapParents; sol.fillMapParents(&n6, mapParents); sol.printMapParents(mapParents); // 测试 depth sol.printAllNodesDepth(mapParents, &n6); // 测试 traverseUpward TreeNode* tempNode = &n2; sol.traverseUpward(tempNode, 1, mapParents); // 测试 lowestCommonAncestor TreeNode* v = &n2; TreeNode* w = &n4; TreeNode* lca = sol.lowestCommonAncestor(&n6, v, w); cout << endl << v->val << ", " << w->val << " 的 LCA 是 " << lca->val << endl << endl; v = &n2; w = &n8; lca = sol.lowestCommonAncestor(&n6, v, w); cout << endl << v->val << ", " << w->val << " 的 LCA 是 " << lca->val << endl << endl; return 0; }
void OmniRobot::init() { period = 200; xw = 75.0; //mm yw = 75.0; //mm Dw = 50.0; //mm vector<float> u1 (2); u1(0) = c1; u1(1) = c1; vector<float> u2 (2); u2(0) = c1; u2(1) = -c1; vector<float> u3 (2); u3(0) = c1; u3(1) = c1; vector<float> u4 (2); u4(0) = c1; u4(1) = -c1; vector<float> n1 (2); n1(0) = c1; n1(1) = -c1; vector<float> n2 (2); n2(0) = -c1; n2(1) = -c1; vector<float> n3 (2); n3(0) = c1; n3(1) = -c1; vector<float> n4 (2); n4(0) = -c1; n4(1) = -c1; vector<float> b1 (2); b1(0) = xw; b1(1) = yw; vector<float> b2 (2); b2(0) = xw; b2(1) = -yw; vector<float> b3 (2); b3(0) = -xw; b3(1) = -yw; vector<float> b4 (2); b4(0) = -xw; b4(1) = yw; Mt(0,0) = n1(0); Mt(0,1) = n1(1); Mt(0,2) = b1(0)*u1(0) + b1(1)*u1(1); Mt(1,0) = n2(0); Mt(1,1) = n2(1); Mt(1,2) = b2(0)*u2(0) + b2(1)*u2(1); Mt(2,0) = n3(0); Mt(2,1) = n3(1); Mt(2,2) = b3(0)*u3(0) + b3(1)*u3(1); Mt(3,0) = n4(0); Mt(3,1) = n3(1); Mt(3,2) = b4(0)*u4(0) + b4(1)*u4(1); Mt = -1 * Mt; cmd(0) = 0.0; cmd(1) = 0.0; cmd(2) = 0.0; pwm(0) = 0.0; pwm(1) = 0.0; pwm(2) = 0.0; pwm(3) = 0.0; omniState = INIT_MODE; movementMode = ROTATE_MODE; power = 20; pplus = 1; }
int main() { typedef DAG::Node<const idpair> INode; // create a set of nodes // the nodes will be kept track of in the Node children and parent collections so // shared_ptr is used. INode n0(idpair(0, 2)); INode n1(idpair(1, 3)); INode n2(idpair(2, 3)); INode n3(idpair(3, 2)); INode n4(idpair(4, 2)); INode n5(idpair(5, 2)); INode n6(idpair(6, 2)); // and now define the polytree // add the directed (parent -> child) branches of the polytree // each link requires an addChild and an addParent n0.addChild(n1); // link between n0 and n1 n1.addChild(n2); // link between n0 and n2 etc n1.addChild(n3); n3.addChild(n6); n3.addChild(n4); n4.addChild(n5); n5.addChild(n6); DAG::BFSRecurseVisitor<INode> bfs; // Start at node 0 for the following examples // Example 1 // BFSVisitor uses an iterative method to traverse // output the Datatype of all children std::cout << std::endl << "TRAVERSE CHILDREN (start Node 0) 1 level" << std::endl; for (auto n : bfs.traverseChildren(n0, 1)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } std::cout << std::endl << "TRAVERSE UNDIRECTED (start Node 5) 2 levels " << std::endl; for (auto n : bfs.traverseUndirected(n5, 2)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } std::cout << std::endl << "TRAVERSE CHILDREN (start Node 0) all levels" << std::endl; for (auto n : bfs.traverseChildren(n0)) { std::cout << n->value().itype << ":" << n->value().ivalue << std::endl; } return 0; }
int main(int argc, char **argv) { ListNode n5(5, NULL); ListNode n4(4, &n5); ListNode n3(3, &n4); ListNode n2(2, &n3); ListNode n1(1, &n2); ListNode *head = s.removeNthFromEnd(&n1, 2); while (head != NULL) { printf("%d ", head->val); head = head->next; } printf("\n"); return 0; }
int main(){ TreeNode n0(0); TreeNode n1(1); TreeNode n2(2); TreeNode n3(3); TreeNode n4(4); TreeNode n5(5); n0.left = &n1; n0.right = &n2; n1.left = &n3; n1.right = &n4; n4.left = &n5; int res = maxDepth(&n0); printf("%d\n", res); return 0; }
TEST(QueueTest, QueueFIFOTest) { // Check that regular queue is FIFO StdQueue queue; Node n1(0,1,4,5), n2(1,2,4,3), n3(2,1,3,6), n4(1,0,4,7); queue.insert(&n1); queue.insert(&n2); queue.insert(&n3); queue.insert(&n4); // Order should be n1,n2,n3,n4 ASSERT_EQ(&n1, queue.removeFront()); ASSERT_EQ(&n2, queue.removeFront()); ASSERT_EQ(&n3, queue.removeFront()); ASSERT_EQ(&n4, queue.removeFront()); }
int main(){ TreeNode n1(1); TreeNode n2(2); TreeNode n3(3); TreeNode n4(4); TreeNode n5(5); TreeNode n6(6); n1.left = &n2; //n1.right = &n5; n2.left = &n3; n2.right = &n4; n5.right = &n6; bool r = hasPathSum(&n1, 1); printf("%s\n", r?"true":"false"); return 0; }
void snake::move_snake() { if(direction!=0) { if(direction==UP){node n('*',head->Pos_x,head->Pos_y-1); insert_body(n);} else if(direction==DOWN){node n2('*',head->Pos_x,head->Pos_y+1); insert_body(n2);} else if(direction==LEFT){node n3('*',head->Pos_x-2,head->Pos_y); insert_body(n3);} else if(direction==RIGHT){node n4('*',head->Pos_x+2,head->Pos_y); insert_body(n4);} if(head->Pos_x!=apple_x||head->Pos_y!=apple_y)//判断是否吃苹果 delete_tail(); else creat_food(); show_food(); } }
TEST(QueueTest, StackTest) { // Check that inserting several nodes to Stack acts as LIFO Stack queue; // yeah, that's terrible naming, w/e Node n1(0,1,4,5,false), n2(1,2,4,3,false), n3(2,1,3,6,false), n4(1,0,4,7,false); queue.insert(&n1); queue.insert(&n2); queue.insert(&n3); queue.insert(&n4); // Order should be n4,n3,n2,n1 ASSERT_EQ(&n4, queue.removeFront()); ASSERT_EQ(&n3, queue.removeFront()); ASSERT_EQ(&n2, queue.removeFront()); ASSERT_EQ(&n1, queue.removeFront()); }
int main() { { /* _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 5 */ Node n1( 6 ); Node n2( 2 ); Node n3( 8 ); Node n4( 0 ); Node n5( 4 ); Node n6( 7 ); Node n7( 9 ); Node n8( 3 ); Node n9( 5 ); n1.left = &n2; n1.right = &n3; n2.left = &n4; n2.right = &n5; n3.left = &n6; n3.right = &n7; n5.left = &n8; n5.right = &n9; const Node * p = lca_bst( &n1, &n8, &n9 ); assert( p == &n5 ); p = lca_bst( &n1, &n2, &n8 ); assert( p == &n2 ); p = lca_bst( &n1, &n7, &n9 ); assert( p == &n1 ); Node n10( 10 ); p = lca_bst( &n1, &n2, &n10 ); assert( p == nullptr ); } return 0; }
TEST(QueueTest, PrioritySortTest) { // Check that inserting several nodes sorts them // in order of f (g+h) PriorityQueue queue; Node n1(0,1,4,5,false), n2(1,2,4,3,false), n3(2,1,3,6,false), n4(1,0,4,7,false); queue.insert(&n1); queue.insert(&n2); queue.insert(&n3); queue.insert(&n4); // Order should be n2,n3,n1,n4 ASSERT_EQ(&n2, queue.removeFront()); ASSERT_EQ(&n3, queue.removeFront()); ASSERT_EQ(&n1, queue.removeFront()); ASSERT_EQ(&n4, queue.removeFront()); }
int main() { std::vector<ListNode*> lists; readFromFile(lists, "klist.txt"); ListNode n1(1), n2(2), n1a(1), n3(3), n4(4), n5(5), n6(6), *result; n1.next = &n3; n2.next = &n4; n4.next = &n6; //lists.push_back(&n1); //lists.push_back(&n2); //lists.push_back(&n5); std::cout << "Calling solution" << std::endl; Solution s; result = s.mergeKLists(lists); s.print(result); return 0; }
int main() { ListNode n1(1); ListNode n2(2); ListNode n3(3); ListNode n4(4); n1.next = &n2; n2.next = &n3; n3.next = &n4; n4.next = &n1; Solution sln; cout << sln.hasCycle(&n1) << endl; return 0; }
int main() { ListNode n1(1); ListNode n2(2); ListNode n3(3); ListNode n4(4); n1.next = &n2; n2.next = &n3; n3.next = &n4; Solution sln; sln.reorderList(&n1); printListNode(&n1); return 0; }