Monday, May 24, 2010

C++ computer programming question 1.please help!?

Write a functiion with double* argument a and int argument length which returns the minimum element in the memory block a.





The following sample task may help:





sample task 1


write a function with a const char* arguments, an int argument length and a character argument c,which which returns the number of characters c in s








int count(const char* s, int length, char c)


{


int i, cnt;


for(i=0, cnt=0; i%26lt; length; ++i)


if(*(s + 1) == c)


++cnt;


return cnt;


}

C++ computer programming question 1.please help!?
//we're assuming length is the number of doubles


//in the memory block, not the number of bytes in


//the memory block. If it's bytes, divide length by


//the sizeof(double)


//which is probably 4


double FindMinimum(double* a, int length)


{


double dLowest = DBL_MAX; //start it at a really big number if DBL_MAX is undefined for you


for(int iIndex = 0; iIndex %26lt; length; iIndex++)


{


if(a[iIndex] %26lt; dLowest)


{


dLowest = a[iIndex];


}


}


return dLowest;


}


No comments:

Post a Comment