Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n = 5, m = 7, MaxNumOfLine = 0, MaxInLine = 0, MaxInAllLines = 0, MaxNumOfColumn = 0, MaxInColumn = 0, MaxInAllColumn = 0;
- int M[5][7] = { {1,1,0,1,1,0,1},
- {0,1,0,0,1,0,0},
- {1,0,0,0,1,1,0},
- {0,1,0,1,1,1,1},
- {0,1,1,0,0,1,1} };
- _asm
- {; строка
- mov ecx, n;
- xor edx, edx;
- xor esi, esi;
- begin_n:
- push ecx;
- mov ecx, m;
- begin_m:
- mov eax, M[esi * 4]; находим максимальное число подряд идущих 1
- cmp eax, 1;
- je itis1;
- cmp edx, MaxInLine;
- jl nodChange;
- mov MaxInLine, edx;
- nodChange:
- inc esi;
- xor edx, edx;
- jmp endOfLine;
- itis1:
- inc esi;
- inc edx;
- endOfLine:
- loop begin_m;
- cmp edx, MaxInLine;
- jl nodChange1;
- mov MaxInLine, edx;
- nodChange1:
- xor edx, edx;
- mov edx, MaxInLine;
- cmp edx, MaxInAllLines;
- jb notMax;
- mov MaxInAllLines, edx;
- mov eax, esi;
- cdq;
- div m;
- mov MaxNumOfLine, eax;
- notMax:
- xor edx, edx;
- mov MaxInLine, 0;
- pop ecx;
- loop begin_n;
- }
- _asm
- {; столбец
- mov ecx, m;
- xor edx, edx;
- xor esi, esi;
- xor ebx, ebx;
- begin_m1:
- push ecx;
- mov esi, ebx;
- mov ecx, n;
- begin_n1:
- mov eax, M[esi * 4];
- cmp eax, 1;
- je itis11;
- cmp edx, MaxInColumn;
- jl nodChange2;
- mov MaxInColumn, edx;
- nodChange2:
- mov eax, m;
- add esi, eax;
- xor edx, edx;
- jmp endOfColumn;
- itis11:
- mov eax, m;
- add esi, eax;
- inc edx;
- endOfColumn:
- loop begin_n1;
- cmp edx, MaxInColumn;
- jl nodChange3;
- mov MaxInColumn, edx;
- nodChange3:
- xor edx, edx;
- mov edx, MaxInColumn;
- cmp edx, MaxInAllColumn;
- jb notMax1;
- mov MaxInAllColumn, edx;
- mov eax, esi;
- cdq;
- div m;
- mov MaxNumOfColumn, edx;
- notMax1:
- xor edx, edx;
- mov MaxInColumn, 0;
- inc ebx;
- pop ecx;
- loop begin_m1;
- }
- cout << "Line with max number of 1 is " << MaxNumOfLine << endl;
- cout << "Column with max number of 1 is " << MaxNumOfColumn+1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement