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 )


  • 相关阅读:
    jsp转向
    什么是 XDoclet?
    tomcat中的几点配置说明
    mysql5问题
    POJ 3734 Blocks
    POJ 2409 Let it Bead
    HDU 1171 Big Event in HDU
    POJ 3046 Ant Counting
    HDU 2082 找单词
    POJ 1286 Necklace of Beads
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350892.html
Copyright © 2011-2022 走看看