برامج

اريدالمساعده [الأرشيف] - برامج نت

المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : اريدالمساعده


سوزي2006
01-28-2007, 06:17 PM
// Lines with comments include stuff needed to make code valid C
// These lines will not affect your work and can be ignored in your assembly
// This code is intended as reference to guide conversion to assembly

int mid(int x, int y)
{
return (x+y)/2;
}

int *bsearch(int *v, int n, int key) // int * returns a pointer (address) to int
{
int left=1, right;
int x;

sort(v,10); // use bubble sort from textbook

right = n;
while ( right >= left )
{
x = mid(left, right);

if ( key < v[x] )
right = x-1;
else
left = x+1;

if ( key == v[x] )
return v+x; // address arithmetic, compiler will figure out correct address
}

return (int*) -1; // the pattren 0xffffffff
}

int main (void)
{
int v [10] = {-2,0,5,7,9,12,17,25,40,128};

bsearch(v, 10, 12);
}



الله يخليكم ردو بسرعه ضروري ابغى الحل بلغة الاسمبلي الله يسعدكم انتم عباقره في البرمجه

:smailes43: