-
Notifications
You must be signed in to change notification settings - Fork 1
/
maincpp
107 lines (103 loc) · 3.1 KB
/
maincpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// 计网课设2.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include"Oper.h"
#include"Insert.h"
#include"Remove.h"
using namespace std;
int main()
{
int m = 1;
Oper G;
G.input();
while (m)
{
cout << "***********************************************************************" << endl;
cout << "********************* 路由表输出系统 *********************" << endl;
cout << "********************* 请选择需要进行的操作 *********************" << endl;
cout << "********************* 1.添加新的路由器 *********************" << endl;
cout << "********************* 2.删除已有路由器 *********************" << endl;
cout << "********************* 3.添加边 *********************" << endl;
cout << "********************* 4.删除边 *********************" << endl;
cout << "********************* 5.打印路由表 *********************" << endl;
cout << "********************* 6.退出 *********************" << endl;
cout << "***********************************************************************" << endl;
int choice = 0;
cout << "请输入操作:" << endl;
cin >> choice;
if (choice == 1)
{
int v1;
int tem;
cout << "请输入你需要添加的新的路由器" << endl;
cin >> v1;
tem = G.insertver(v1);
if (tem == 1)
{
int n;
cout << "添加完成" << endl;
cout << "是否接着添加边?1/是,0/否" << endl;
cin >> n;
while (n)
{
int v1, v2, cost;
cout << "请输入你需要添加的边的两个顶点" << endl;
cin >> v1 >> v2;
cout << "请输入你需要添加的边的权值" << endl;
cin >> cost;
G.insertedg(v1, v2, cost);
cout << "添加完成" << endl;
cout << "是否继续添加?1/是,0/否" << endl;
cin >> n;
}
}
else if (tem == 0)
cout << "添加失败" << endl;
}
else if (choice == 2)
{
int v1;
cout << "请输入你需要删除的路由器" << endl;
cin >> v1;
G.removever(v1);
cout << "删除完成" << endl;
}
else if (choice == 3)
{
int v1, v2, cost;
cout << "请输入你需要添加的边的两个顶点" << endl;
cin >> v1 >> v2;
cout << "请输入你需要添加的边的权值" << endl;
cin >> cost;
G.insertedg(v1, v2, cost);
cout << "添加完成" << endl;
}
else if (choice == 4)
{
int v1, v2;
cout << "请输入你需要删除的边的两个顶点" << endl;
cin >> v1 >> v2;
G.removeedg(v1, v2);
cout << "删除完成" << endl;
}
else if (choice == 5)
{
int x;
cout << "请问你需要生成第几个路由器的路由表" << endl;
cin >> x;
int* tem = G.create(x);
cout << "生成完毕" << endl;
G.output(tem, x);
}
else if(choice==6)
{
exit(-1);
}
else
cout << "输入有误,请确认后重新输入" << endl;
cout << "是否继续进行操作?1/是,0/否" << endl;
cin >> m;
if (m != 1 && m != 0)
cout << "输入有误,请确认后重新输入" << endl;
}
}