zoukankan      html  css  js  c++  java
  • 链式前向星



     “链式前向星”是我创造的(至少Baidu上没有搜到)名词,或许这种数据结构有其他更加正规易懂的名字,但我还是没有搜到。(有一个资料称之为加上next数组前向星,但这个名字实在不好)

    该数据结构可能是Jason911神牛或其他神牛发明的,我只是起了个名字并写了这个课件。

    Malash

    2009年10月18日0:34:50

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

     

    链式前向星及其简单应用 - Malash - Malash的OI生涯

    示例程序:
     7
    1 2
    2 3
    3 4
    1 3
    4 1
    1 5
    4 5

    #include <iostream>
    #include <cstring>
    #include <cstdio> 

    using namespace std;

    const int MaxV=1000;
    const int MaxE=10000;

    typedef struct node
    {
        int to;
        int next;
    }Edge;

    Edge E[MaxE];
    int Adj[MaxV];
    int Size;

    void Init()
    {
        Size=0;
        memset(Adj,-1,sizeof(Adj));
    }

    void Add_Edge(int u,int v)
    {
        E[Size].to=v;
        E[Size].next=Adj;
        Adj=Size++;
    }

    void Show(int u)
    {
        for(int i=Adj;~i;i=E.next)
        {
            printf("%d--->%d ",u,E.to);
        }
    }

    int main()
    {
        int m;
        cin>>m;
        Init();
        while(m--)
        {
            int a,b;
            cin>>a>>b;
            Add_Edge(a,b);
        }

        for(int i=1;i<=5;i++)
        {
            Show(i);
        }

        return 0;
    }
    * This source code was highlighted by YcdoiT. ( style: Codeblocks )


  • 相关阅读:
    【剑指offer】24.反转链表
    【剑指offer】22. 链表中倒数第k个节点
    【每日一题-leetcode】84.柱状图中最大的矩形
    activity切换动画
    取消ActionBar的方法
    软工概论学习一
    软工概论学习二
    屏幕滑动监测以及触发事件
    Android 动画解释
    shape 学习
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350892.html
Copyright © 2011-2022 走看看