fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <list>
  4. using namespace std ;
  5.  
  6. //#define N 17
  7.  
  8. ifstream infile ("el.txt"); //Input file
  9. ofstream outfile("matrix.txt"); //Output file
  10.  
  11.  
  12.  
  13. int main (){
  14. int a, b;
  15. int n;
  16.  
  17. infile >> n ;
  18.  
  19. int** matrix = new int*[n];
  20. for (int i = 0; i < n; ++i)
  21. matrix[i] = new int[n];
  22.  
  23.  
  24. while (infile >> a && a!=-1){
  25. infile >> b;
  26. matrix[a-1][b-1] = 1;
  27. matrix[b-1][a-1] = 1;
  28. }
  29.  
  30. for (int i=0; i<n; i++){
  31. for (int j=0; j<n; j++){
  32. if (matrix[i][j] == 1)
  33. outfile << " 1 " << " " ;
  34. else
  35. outfile << " 9 " << " " ;
  36. }
  37. outfile << endl ;
  38. }
  39.  
  40. for (int i = 0; i < n; ++i)
  41. delete [] matrix[i];
  42. delete [] matrix;
  43.  
  44. return 0;
  45. }
  46. your text goes here
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty