English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a function

double* maximum(double a[ ], int a_size)

that returns a pointer to the maximum value of an array of floatin-point data.If a_size is 0, return NULL.

2007-01-05 19:13:40 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

check out http://www.pscode.com for great examples.

2007-01-05 19:16:53 · answer #1 · answered by Richard H 7 · 0 0

Shhhh... your teacher may be watching!

int idx, largeVal=0, largePos=0;
for (idx=0; idx < a_size; idx++)
if (a[idx]>largestPos) {
largeVal=a[idx];
largePos=idx;
}

now for the hard part... you have the value and the position. Change the above to return a pointer to the correct location. :)

2007-01-06 03:22:15 · answer #2 · answered by BigRez 6 · 0 0

Come again?!?!

2007-01-06 03:17:00 · answer #3 · answered by ? 3 · 0 0

fedest.com, questions and answers