Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int a, i = 0; //a - num, i - order
- cout << "Type a: ";
- cin >> a;
- _asm {
- //count order
- mov eax, a
- cmp eax,0 //
- je end_yes_
- beg_ord:
- cmp eax, 0
- jle end_ord
- mov ebx, 10
- xor edx, edx
- cdq
- idiv ebx
- //i++
- mov ebx, i
- add ebx, 1
- mov i, ebx
- jmp beg_ord
- end_ord :
- }
- int l, r;// left and right temp vars
- _asm{
- cmp ebx,1 //num = digit
- je end_yes_
- //divide i by 2
- mov eax, i
- mov ebx, 2
- xor edx, edx
- cdq
- idiv ebx
- mov ecx, eax
- mov esi,a
- //beg division
- beg_div:
- // save ecx as external loop counter
- mov edi,ecx
- //devide a by 10
- mov eax,esi
- mov ebx,10
- xor edx,edx
- cdq
- idiv ebx
- mov r,edx //fill r
- mov esi,eax //fill esi
- //i-2
- mov eax,i
- sub eax,2
- mov i,eax
- //10^i (current i)
- mov ecx,i //set ecx as internal loop counter
- mov eax,1
- cmp ecx, 0
- je next_step_
- mov ebx,10
- beg_pow:
- imul ebx
- loop beg_pow
- //esi/10^i
- next_step_ :
- mov ebx,eax
- mov eax,esi
- xor edx, edx
- cdq
- idiv ebx
- mov l,eax //fill l
- mov esi,edx// fill esi
- //compare
- mov eax,r
- mov ebx,l
- cmp eax,ebx
- jne end_no_
- //set ecx as external loop counter
- mov ecx,edi
- loop beg_div
- }
- end_yes_:
- cout << "Number " << a << " is symmetric" << endl;
- system("pause");
- return 0;
- end_no_:
- cout << "Number " << a << " is not symmetric" << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement