Home > Software engineering >  Help: to calculate the maximum of absolute value algorithm
Help: to calculate the maximum of absolute value algorithm

Time:09-21

As title, there is a negative, and is not an integer

CodePudding user response:

# define fabsmax (a, b) (Max (fabs (a), fabs (b)))

CodePudding user response:

//code is as follows, according to the need to change,,


# include
using namespace std;
#include

# include

Float the date [8]={200.1, 40.5, 80,99.367, 0, 778.354, 666454235};
Int main ()
{
for (int i=0; I & lt; (sizeof (date)/sizeof (date [0]) - 1); I++)//get the length of the array recycle, large behind to a
{
If (abs (date [I]) & gt; Abs (date/I + 1))
{
Float a=date [I];
The date [I + 1)=a;
}
}
Cout & lt; <"The number of 8 absolute value of the largest number is:" & lt; //cout & lt; //cout. Precision (4);//the two sentences is to control the output data decimal digits
//cout & lt; Cout & lt; getchar();
}

CodePudding user response:

Yesterday was your Posting for absolute value and the algorithm of linear linearity? Before I answer you, then your posts were deleted,,

CodePudding user response:

 float date [8]={200.1, 40.5, 80,99.367, 0, 778.354, 666454235}; 
Float Max=0;
for (int i=0; I & lt; (sizeof (date)/sizeof (date [0])); I++)
{
If (abs (date [I]) & gt; Max)
{
Max=date [I];
}
}

CodePudding user response:

Max vs compiler built-in function
  • Related