Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int n = 10;
- int main() {
- int a[n];
- cout << "Type a["<<n<<"] ";
- for (int i = 0; i < n;i++) {
- cin >> a[i];
- }
- int aq[n], ae[n];
- int mq, me; //max quantity, max element(quantity)
- int q, e; // quantity, element (for output)
- int c=0;//counter for aq and ae
- _asm
- {
- //sort
- mov ecx,n //set external ecx
- sub ecx,2
- beg_1_1_:
- //{
- mov ebx, ecx //save external ecx
- mov ecx, n //set internal ecx
- sub ecx, 2
- beg_1_2_ :
- ///{
- mov eax, ecx
- mov edx, 4
- imul edx
- mov esi, a[eax] // esi=a[ecx*4]
- add eax,4
- mov edi, a[eax] // esi=a[(ecx+1)*4]
- cmp esi,edi
- jl LESS
- ////{
- mov eax, ecx
- mov edx, 4
- imul edx
- mov a[eax],edi // swap
- add eax,4
- mov a[eax],esi //
- ////}
- LESS:
- ///}
- loop beg_1_2_
- //}
- mov ecx, ebx //set external ecx from ebx
- loop beg_1_1_
- //
- mov ecx,n //counter
- add ecx,1
- mov esi,0 //offset for a[]
- mov edi,0 //offset for aq[] and ae[]
- mov eax,a[esi]
- mov e,eax // e=a[esi]
- mov eax,0
- mov q,eax //q=0
- mov eax,a[esi]
- mov me,eax //me=a[esi]
- mov mq, eax //q=0
- beg_2_1:
- //{
- mov ebx,e
- cmp ebx,a[esi]
- je EQL_2_1
- ///{
- mov eax,q
- mov aq[edi],eax //aq[edi]=q
- mov eax, e
- mov ae[edi], eax //ae[edi]=e
- add edi,4 //edi+=4
- mov eax,c //c++
- add eax,1
- mov c,eax
- mov eax,mq
- cmp eax,q
- jg GR_2_1
- ////{
- mov eax,q
- mov mq,eax
- mov eax, e
- mov me, eax
- ////}
- ////
- jmp SKIP
- beg_2_2:
- jmp beg_2_1
- SKIP :
- ////
- GR_2_1:
- mov eax,1
- mov q,eax
- mov eax,a[esi]
- mov e,eax
- jmp NEXT_2_1
- ///}
- EQL_2_1:
- ///{
- mov eax,q //q++
- add eax,1
- mov q,eax
- ///}
- NEXT_2_1:
- //}
- add esi,4 //esi+=4
- loop beg_2_2
- }
- for (int i = 0; i < n; i++) {
- cout << a[i] << " ";
- }
- cout<< endl;
- for (int i = 0; i<c; i++)
- {
- cout << "Elem " << ae[i] << " - " << aq[i] << endl;
- }
- cout << "Max elem " << me << " - " << mq << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment