-
Notifications
You must be signed in to change notification settings - Fork 5
/
IO.cc
69 lines (52 loc) · 1.1 KB
/
IO.cc
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
#include <string>
#include <iostream>
#include <vector>
#include "denseGRAPH.cc"
using namespace std;
template<class Graph>
class IO {
public:
static void show (Graph&);
static void scanEZ (Graph &);
static void scan (Graph &);
};
template<class Graph> void IO<Graph>::show (Graph& G){
int i, j;
Edge e;
for (i = 0; i < G.V(); i++)
for (j = 0; j < G.V(); j++){
e = Edge(i, j);
cout << G.edge(e) << " ";}
cout << endl;
}
template<class Graph> void IO<Graph>::scanEZ (Graph & G){
vector<int> v;
vector<int> w;
Edge e;
int n;
// int v, w;
int i = 0;
while (cin >> n)
{
if (i%2 == 0){
cout << n << endl;
v.push_back (static_cast<int>(n));}
else{
cout << abs(n) << endl;
w.push_back (static_cast<int>(abs(n)));}
i++;
}
for (i=0; i < v.size(); i++)
{
e = Edge (v[i], w[i]);
G.insert (e);
cout << e.v << " -> " << e.w << endl;
}
}
int main(){
int V = 20;
DenseGRAPH G(V);
IO<DenseGRAPH>::scanEZ (G);
IO<DenseGRAPH>::show (G);
return 0;
}