首先在ns3.25/examples/tutorial/下找到 first.cc文件,将他拷贝到到scratch目录下. 然后为了方便将代码打出来 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU
题目:给定一个单链表,交换两个相邻的节点,且返回交换之后的头节点 举例: Given 1->2->3->4, you should return the list as 2->1->4->3. 解题思路: 题目本身很简单,但是要注意一些细节: 1. 两对节点之间的连接 2. 如果只剩下一个节点,则不需要交换 代码如下: /** * Definition for singly-linked list. * public class ListNode { * int v