📄 网2.cpp
字号:
#include <iostream>
#include <string>
#include <stdio.h>
#include <Windows.h>
#include <vector>
using namespace std;
//关于此图的网
//*************************************************************************//
//************************a-----b******************************************// */
//************************|\ /|******************************************//
//************************| \ / |******************************************//
//************************| e |******************************************//
//************************| / \ |******************************************//
//************************|/ \|******************************************//
//************************d-----c******************************************//
//*************************************************************************//
struct Node
{
string name;
vector<Node*> v;
};
Node a,b,c,d,e;
void connect(Node *x,Node *y)//连接两点,建立联系
{
x->v.push_back(y);
y->v.push_back(x);
}
void paint2(Node* x)//另法
{
vector<Node*> vv=x->v;
for(int i=0;i<vv.size();i++)
cout<<vv[i]->name<<endl;
}
void paint(Node* x)//显示与查找点关联的点的内容
{
vector<Node*>::const_iterator i;
for(i=(x->v).begin(); i!=(x->v).end(); ++i)
{
cout<<(*i)->name<<endl;
}
}
void main()
{
a.name="我的书";
b.name="我的朋友在帮我写书";
c.name="我的朋友";
d.name="我的朋友在看我写的书";
e.name="我";
/*****建立连接****/
connect(&a,&b);connect(&b,&c);connect(&c,&d);connect(&d,&a);
connect(&a,&e);connect(&b,&e);connect(&c,&e);connect(&d,&e);
/**查找连接e的点**/
cout<<"输入需要的节点:"
cout<<"查找到:"<<endl<<endl;
paint2(&e);
cout<<endl;
system("pause");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -