Home > Back-end >  Piecewise function to compare the size
Piecewise function to compare the size

Time:10-07

In c + + how to realize the two piecewise function to compare size,
Such as f (x)
When x belong to [0, 5) f (x)=x + 20;
When x belong to [5, 13] f (x)=25;
When x belongs to 30 [13] f (x)=3 x - 14;

Another function g (x) for:
When x belong to [3, 10] f (x)=x + 15;
When x belong to [10, 10] f (x)=35;


The problem is this:
Compare the above two function, when the value of g (x) less than the value of f (x), that the value of f (x) is equal to g (x) the value of the
And when the value of g (x) is greater than the f (x), f (x) values,

Validate solutions,

CodePudding user response:

No solution this problem, two function domain is different, one is [0, 30], a [23] 3,, x is 0 or 30, how to compare?

CodePudding user response:

When is beyond the scope definition, an exception, it is a common method,
I.e., f (x) 3 & lt; X<23, you have to calculate f (100), so this is not defined, an exception can be simply,

As for the user interface, it is received after abnormal, showed abnormal information,
  • Related