Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. ifstream fin("input.in");
  5. ofstream fout("output.out");
  6.  
  7. int main()
  8. {
  9.  
  10. int n, m, top1, top2;
  11. fin >> n >> m;
  12.  
  13. int *array = new int[n, n];
  14.  
  15. for (int i = 0; i < n; i++) // заполняет массив нулями
  16. {
  17. for (int j = 0; j < n; j++)
  18. {
  19. array[i, j] = 0;
  20. }
  21. }
  22.  
  23. for (int i = 0; i < m; i++) // считывает из файла номера вершин и присваивает единицы элементам (вершина1, вершина2)
  24. {
  25. fin >> top1 >> top2;
  26. array[top1, top2] = 1;
  27. }
  28.  
  29. for (int i = 0; i < n; i++) // выводит массив
  30. {
  31. for (int j = 0; j < n; j++)
  32. {
  33. fout << array[i, j] << ' ';
  34. }
  35.  
  36. fout << endl;
  37. }
  38.  
  39. delete [] array;
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement