c# - 如何从双向链表c#中打印每个列表中的素数(每行五个数字)
问题描述
如何从文本文件的双向链表中显示素数?
public void middleOfList()
{
if (head == null) ;
if (head.next == null || head.next.next == null) ;
Node slow = head, fast = head.next.next;
// iterate till the middle element
while (fast != null && fast.next != null)
{
slow = slow.next;//Add New nodeto the middle of the linked list.
fast = fast.next.next; //Add new node to the last of the linked list.
}
if (fast != null) slow = slow.next;
Console.WriteLine("The Middle number of list is: " + slow.data);
}
}
解决方案
推荐阅读
- vector - OpenCL 向量显式转换为标量序列
- r - 如何在 Shiny R 中模块化反应函数
- html - 将html转换为pdf时防止表格单元格跨页
- python - 如果我的玩家降落在某个街区,我如何杀死它
- firebase - 如何从 Firebase 动态链接访问 Ionic 应用中的特定页面?
- c++ - 我无法理解特定的语法
- typescript - 等价于部分
例如方法? - aws-lambda - “SAM 本地调用”是否支持 EFS?
- c# - SignOutAsync 不退出
- javascript - 将值传递给 ASP.NET MVC 控制器时具有空项的 JavaScript 数组