如何用整数对作为边来建立图形的邻接矩阵

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/10 05:39:48

如何用整数对作为边来建立图形的邻接矩阵
如何用整数对作为边来建立图形的邻接矩阵

如何用整数对作为边来建立图形的邻接矩阵

#include <iostream>
using namespace std;
struct Stack
{
int data[100];
int top;
};
typedef struct Stack stack;
void Initial(stack &S);
int Pop(stack &s);
void Push(Stack &s,int e);
void main()
{
stack s;
Initial(s);
Push(s,1);
Push(s,2);
Push(s,3);
cout<<Pop(s)<<endl;
cout<<Pop(s)<<endl;
Push(s,4);
cout<<Pop(s)<<endl;
}
void Initial(stack &s)
{
s.top=-1;
}
void Push(stack &s,int e)
{
s.data[++s.top]=e;
}
int Pop(stack &s)
{
return s.data[s.top--];
}