Advertisement
Guest User

Untitled

a guest
May 31st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n = 5, m = 7, MaxNumOfLine = 0, MaxInLine = 0, MaxInAllLines = 0, MaxNumOfColumn = 0, MaxInColumn = 0, MaxInAllColumn = 0;
  7. int M[5][7] = { {1,1,0,1,1,0,1},
  8. {0,1,0,0,1,0,0},
  9. {1,0,0,0,1,1,0},
  10. {0,1,0,1,1,1,1},
  11. {0,1,1,0,0,1,1} };
  12. _asm
  13. {; строка
  14. mov ecx, n;
  15. xor edx, edx;
  16. xor esi, esi;
  17. begin_n:
  18. push ecx;
  19. mov ecx, m;
  20. begin_m:
  21. mov eax, M[esi * 4]; находим максимальное число подряд идущих 1
  22. cmp eax, 1;
  23. je itis1;
  24. cmp edx, MaxInLine;
  25. jl nodChange;
  26. mov MaxInLine, edx;
  27. nodChange:
  28. inc esi;
  29. xor edx, edx;
  30. jmp endOfLine;
  31. itis1:
  32. inc esi;
  33. inc edx;
  34. endOfLine:
  35. loop begin_m;
  36.  
  37.  
  38. cmp edx, MaxInLine;
  39. jl nodChange1;
  40. mov MaxInLine, edx;
  41. nodChange1:
  42. xor edx, edx;
  43.  
  44.  
  45.  
  46. mov edx, MaxInLine;
  47. cmp edx, MaxInAllLines;
  48. jb notMax;
  49. mov MaxInAllLines, edx;
  50. mov eax, esi;
  51. cdq;
  52. div m;
  53. mov MaxNumOfLine, eax;
  54. notMax:
  55. xor edx, edx;
  56. mov MaxInLine, 0;
  57. pop ecx;
  58. loop begin_n;
  59. }
  60.  
  61. _asm
  62. {; столбец
  63. mov ecx, m;
  64. xor edx, edx;
  65. xor esi, esi;
  66. xor ebx, ebx;
  67. begin_m1:
  68. push ecx;
  69. mov esi, ebx;
  70. mov ecx, n;
  71. begin_n1:
  72. mov eax, M[esi * 4];
  73. cmp eax, 1;
  74. je itis11;
  75. cmp edx, MaxInColumn;
  76. jl nodChange2;
  77. mov MaxInColumn, edx;
  78. nodChange2:
  79. mov eax, m;
  80. add esi, eax;
  81. xor edx, edx;
  82. jmp endOfColumn;
  83. itis11:
  84. mov eax, m;
  85. add esi, eax;
  86. inc edx;
  87. endOfColumn:
  88. loop begin_n1;
  89. cmp edx, MaxInColumn;
  90. jl nodChange3;
  91. mov MaxInColumn, edx;
  92. nodChange3:
  93. xor edx, edx;
  94.  
  95. mov edx, MaxInColumn;
  96. cmp edx, MaxInAllColumn;
  97. jb notMax1;
  98. mov MaxInAllColumn, edx;
  99. mov eax, esi;
  100. cdq;
  101. div m;
  102. mov MaxNumOfColumn, edx;
  103. notMax1:
  104. xor edx, edx;
  105. mov MaxInColumn, 0;
  106. inc ebx;
  107. pop ecx;
  108. loop begin_m1;
  109. }
  110. cout << "Line with max number of 1 is " << MaxNumOfLine << endl;
  111. cout << "Column with max number of 1 is " << MaxNumOfColumn+1 << endl;
  112.  
  113. return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement