Advertisement
Guest User

LLtoMA

a guest
May 28th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int LL[100][100],MA[100][100];
  5.  
  6. int n;
  7. int read_data()
  8. {
  9. fstream f;
  10. f.open("LLtoMA.txt",ios::in);
  11. f>>n;
  12.  
  13.  
  14. for(int i=1;i<=n;i++)
  15. for(int j=1;j<=n;j++)
  16. {
  17.  
  18. f>>LL[i][j];
  19.  
  20.  
  21.  
  22. }
  23. f.close();
  24. }
  25. int convert()
  26. {
  27. for(int i=1;i<=n;i++)
  28. {
  29.  
  30. for(int j=1;j<=n;j++)
  31.  
  32. {
  33. if(LL[i][j]!=0)
  34. {
  35. MA[i][LL[i][j]]=1;
  36.  
  37. }
  38. else{ MA[i][LL[i][j]]=0;}
  39.  
  40. }
  41.  
  42. }
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49. int main()
  50. {
  51. read_data();
  52.  
  53.  
  54.  
  55.  
  56. convert();
  57.  
  58. for(int i=1;i<=n;i++)
  59. {for(int j=1;j<=n;j++)
  60. {
  61. cout<<MA[i][j];
  62. }
  63. cout<<endl;
  64. }
  65.  
  66. }
  67.  
  68.  
  69.  
  70.  
  71. /* Fisierul
  72. 5
  73. 2 5 0 0 0
  74. 1 3 5 0 0
  75. 2 4 0 0 0
  76. 3 5 0 0 0
  77. 1 2 4 0 0
  78. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement