-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBai3.cpp
More file actions
64 lines (62 loc) · 1.39 KB
/
Copy pathBai3.cpp
File metadata and controls
64 lines (62 loc) · 1.39 KB
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
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream in, out;
in.open("input1_1.txt",ios_base::in);
out.open("output1_1.txt",ios_base::out);
int n, x, y, t;
in >> n;
int arr[n][n] = {};
while(!in.eof())
{
in.ignore(4,' ');
y = in.get();
if(y == '\n'){
x++;
continue;
}
arr[x][y-'0'-1] = 1;
}
cout << "Ma tran ke bieu dien do thi: " << endl;
out <<endl << "Ma tran ke bieu dien do thi: " << endl;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
cout << arr[i][j] << ' ';
out << arr[i][j] << ' ';
}
cout << endl;
out << endl;
}
cout <<endl << "Danh sach canh cua do thi: " << endl;
out <<endl << "Danh sach canh cua do thi: " << endl;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
if(arr[i][j]&&i<j){
cout << i+1 << " " << j+1<< endl;
out << i+1 << " " << j+1<< endl;
}
}
}
cout <<endl << "Bac cua cac dinh trong do thi: " << endl ;
out <<endl << "Bac cua cac dinh trong do thi: " << endl;
for(int i =0, k =0;i < n;i++,k=0){
cout << "Bac cua dinh " << char( i + 'a') << " = ";
out << "Bac cua dinh " << char( i + 'a') << " = ";
for(int j = 0;j < n;j++){
if(arr[i][j]){
k++;
}
}
cout << k << endl;
out << k << endl;
}
// for(int i = 0;i < n;i++){
// for(int j = 0;j < n;j++){
// cout << arr[i][j] << ' ';
// out << arr[i][j] << ' ';
// }
// cout << endl;
// out << endl;
// }
}