惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - 昊子

工作流参考模型(Workflow Reference Model) DNN default document的异常错误 如何使用GoogleCode提供的SVN Source Control服务 Norton PartitionMagic 8.0 Resizing Boot Partition 智能提示和那些值得崇拜的人 推荐一个Flex & AIR皮肤站点 SessionDiskCache 0.1版发布 Flex locale Flex Repeater 多层嵌套 从没走远 SubmitMask 1.0 发布 如何获取Footer中的子控件 DNN学习笔记 之一 配置 使用NHibernate时产生的一个错误 NHibernate官方文档 之 NHibernate指南-前言 C#事件编程 静态构造函数和静态成员变量初始化的调用时间 NHibernate和SqlImage 结束无谓的讨论吧
C#反转单向链表
昊子 · 2006-06-22 · via 博客园 - 昊子

    class Class1
    
{
        [STAThread]
        
static void Main(string[] args)
        
{
            
//初始化链表
            LineNote startnote = new LineNote( "1" );
            LineNote note 
= startnote;
            
forint i = 2; i<= 5 ;i ++ )
            
{
                note.Next 
= new LineNote( i.ToString() );
                note 
= note.Next;
            }

            note 
= startnote;
            
//输出
            while ( note!=null )
            
{
                System.Console.WriteLine( note.Note );
                note 
= note.Next;
            }

            
//开始反转
            note = startnote;
            LineNote temp 
= note;
            
while ( temp != null )
            
{
                note 
= startnote;
                
if ( temp != startnote )
                
{
                    startnote 
= temp;
                    temp 
= temp.Next;
                    startnote.Next 
= note;
                }

                
else
                
{
                    temp 
= temp.Next;
                    note.Next
= null;
                }

            }

            再次输出
            note 
= startnote;
            
while ( note!=null )
            
{
                System.Console.WriteLine( note.Note );
                note 
= note.Next;
            }

        }

    }


    
class LineNote
    
{
        
public string Note;
        
public LineNote Next;
        
public LineNote( string note)
        
{
            Note
=note;
        }

    }

很有趣的练习:)