Nagy_Szabolcs

graf 1

Sep 13th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. void beolvasas(int mat[][2], int&n, int& m ) {
  7.     ifstream fin("ellista.txt");
  8.  
  9.     fin >> n >> m;
  10.  
  11.     for (int i = 0; i < m; i++) {
  12.         fin >> mat[i][0] >> mat[i][1];
  13.     }
  14. }
  15.  
  16. void ellista_kiiratas(int mat[][2],int m) {
  17.     for (int i = 0; i < m; i++) {
  18.         cout << mat[i][0] << ' ' << mat[i][1] << endl;
  19.     }
  20. }
  21.  
  22. void pp_mat_tolt(int mat[][2],int pp_mat[][50], int m) {
  23.  
  24.     for (int i = 0; i < m; i++) {
  25.         pp_mat[mat[i][0]-1][mat[i][1]-1] = 1;
  26.     }
  27. }
  28.  
  29. void ki_pp_mat(int pp_mat[][50], int n) {
  30.     int i, j;
  31.  
  32.     for (i = 0; i < n; i++) {
  33.         for (j = 0; j < n; j++)
  34.             cout << pp_mat[i][j] << ' ';
  35.         cout << endl;
  36.     }
  37. }
  38.  
  39. int main()
  40. {
  41.     int mat[50][2], n, m;
  42.     beolvasas(mat,n,m);
  43.     ellista_kiiratas(mat, m);
  44.  
  45.     cout << endl << endl;
  46.     int pp_mat[50][50] = {};
  47.     pp_mat_tolt(mat,pp_mat,m);
  48.     ki_pp_mat(pp_mat,n);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment