Arrays Introduction

  • + 0 comments

    For those of you who are wondering how the 1st while loop will terminate , it will terminate only if you type 'false' or 'eof' . It is a fancy way of solving this question but it is not optimised way because it takes a hell lot of machine cycles and instructions . take a look

    while (cin >> A[i++] && (i < N)); 00B324BD mov eax,dword ptr [i]
    00B324C0 mov ecx,dword ptr [A]
    00B324C3 lea edx,[ecx+eax*4]
    00B324C6 mov dword ptr [ebp-11Ch],edx
    00B324CC mov eax,dword ptr [i]
    00B324CF add eax,1
    00B324D2 mov dword ptr [i],eax
    00B324D5 mov esi,esp
    00B324D7 mov ecx,dword ptr [ebp-11Ch]
    00B324DD push ecx
    00B324DE mov ecx,dword ptr [imp?cin@std@@3V?char_traits@D@std@@@1@A (0B3D098h)]
    00B324E4 call dword ptr [__imp_std::basic_istream >::operator>> (0B3D09Ch)]
    00B324EA cmp esi,esp
    00B324EC call __RTC_CheckEsp (0B312DFh)
    00B324F1 mov dword ptr [ebp-0FCh],eax
    00B324F7 mov edx,dword ptr [ebp-0FCh]
    00B324FD mov eax,dword ptr [edx]
    00B324FF mov ecx,dword ptr [ebp-0FCh]
    00B32505 add ecx,dword ptr [eax+4]
    00B32508 mov esi,esp
    00B3250A call dword ptr [__imp_std::ios_base::operator bool (0B3D0D0h)]
    00B32510 cmp esi,esp
    00B32512 call __RTC_CheckEsp (0B312DFh)
    00B32517 movzx ecx,al
    00B3251A test ecx,ecx
    00B3251C je main+0E8h (0B32528h)
    00B3251E mov eax,dword ptr [i]
    00B32521 cmp eax,dword ptr [N]
    00B32524 jge main+0E8h (0B32528h)
    00B32526 jmp main+7Dh (0B324BDh)
    while (cout << A[--N] << ' ' && N); 00B32528 mov eax,dword ptr [N]
    00B3252B sub eax,1
    00B3252E mov dword ptr [N],eax
    00B32531 push 20h
    00B32533 mov esi,esp
    00B32535 mov ecx,dword ptr [N]
    00B32538 mov edx,dword ptr [A]
    00B3253B mov eax,dword ptr [edx+ecx*4]
    00B3253E push eax
    00B3253F mov ecx,dword ptr [imp?cout@std@@3V?char_traits@D@std@@@1@A (0B3D0D4h)]
    00B32545 call dword ptr [__imp_std::basic_ostream >::operator<< (0B3D0A4h)]
    00B3254B cmp esi,esp
    00B3254D call __RTC_CheckEsp (0B312DFh)
    00B32552 push eax
    00B32553 call std::operator<< > (0B314A6h)
    00B32558 add esp,8
    while (cout << A[--N] << ' ' && N); 00B3255B mov dword ptr [ebp-108h],eax
    00B32561 mov ecx,dword ptr [ebp-108h]
    00B32567 mov edx,dword ptr [ecx]
    00B32569 mov ecx,dword ptr [ebp-108h]
    00B3256F add ecx,dword ptr [edx+4]
    00B32572 mov esi,esp
    00B32574 call dword ptr [__imp_std::ios_base::operator bool (0B3D0D0h)]
    00B3257A cmp esi,esp
    00B3257C call __RTC_CheckEsp (0B312DFh)
    00B32581 movzx eax,al
    00B32584 test eax,eax
    00B32586 je main+150h (0B32590h)
    00B32588 cmp dword ptr [N],0
    00B3258C je main+150h (0B32590h)
    00B3258E jmp main+0E8h (0B32528h)