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 )


  • 相关阅读:
    ES6新特性
    ng-bind与ng-medol 区别
    验证输入两次密码是否一致angularjs
    最全的node.js安装步骤
    JAVA基础
    localStorage 个人使用总结
    mac中怎么安装python3
    macbook配置homebrew以及安装python3
    python之函数进阶
    mysql数据库入门
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350892.html
Copyright © 2011-2022 走看看