Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "rus");
- int v, r, x, y;
- cout << "Введите количество вершин = ";
- cin >> v;
- cout << "Введите колличество рёбер = ";
- cin >> r;
- int C[5][5];
- int B[5][9];
- for (int i = 0; i<v; i++) {
- for (int j = 0; j<v; j++) {
- C[j][i] = 0;
- }
- }
- for (int i = 0; i<v; i++) {
- for (int j = 0; j<r; j++) {
- B[i][j] = 0;
- }
- }
- cout << endl;
- for (int i = 0; i<r; i++) {
- cout << "Введите откуда выходит ребро № " << i + 1 << " : ";
- cin >> x;
- cout << "Введите куда входит ребро № " << i + 1 << " : ";
- cin >> y;
- C[y - 1][x - 1] += 1;
- B[x - 1][i] = 1;
- B[y - 1][i] -= 1;
- }
- cout << "Матрица смежности имеет вид:" << endl;
- for (int i = 0; i<v; i++) {
- for (int j = 0; j<v; j++) {
- cout << C[j][i] << " ";
- }
- cout << endl;
- }
- cout << "Матрица инцидентности имеет вид:" << endl;
- for (int i = 0; i<v; i++) {
- for (int j = 0; j<r; j++) {
- cout << setw(4) << B[i][j] << " ";
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement