1. templates can be used for data types, such as C ++, which is relatively simple, but C is difficult.
2. If there is no data type, it is necessary to judge all points for execution. Time is complex and time is not optimized, and the code is easy to understand. For example, test the right triangle.
VaR Epsilon = 0.00000000001; // small numbers to be tested. </P> <p> // test the integer function. <Br/> function integercheck (a, B, c) <br/>{< br/> // test. <Br/> If (A * A) = (B * B) + (C * C) <br/> return true; </P> <p> return false; <br/>}// The End Of The integer check function. </P> <p> // test the floating point function. <Br/> function floatcheck (a, B, c) <br/>{< br/> // obtain the test value. <Br/> var Delta = (A * A)-(B * B) + (C * C ))) </P> <p> // absolute value required for testing <br/> Delta = math. ABS (DELTA); </P> <p> // if the difference is smaller than Epsilon, it is quite close. <Br/> If (delta <epsilon) <br/> return true; </P> <p> return false; <br/>}// the end of the floating point check function. </P> <p> // ternary check. <Br/> function checktriplet (a, B, c) <br/>{< br/> // create a temporary variable for exchanging values <br/> var D = 0; </P> <p> // first move the longest value to the location "". </P> <p> // if necessary, exchange a and B <br/> If (B> A) <br/>{< br/> d =; <br/> A = B; <br/> B = D; <br/>}</P> <p> // if necessary, exchange A and C <br/> If (C>) <br/>{< br/> d = A; <br/> A = C; <br/> C = D; <br/>}</P> <p> // test all three values to see if they are integers? <Br/> If (a % 1) = 0) & (B % 1) = 0) & (C % 1) = 0) <br/>{< br/> // If yes, use the exact check. <Br/> return integercheck (A, B, C); <br/>}< br/> else <br/>{< br/> // if not, take as close as possible. <Br/> return floatcheck (A, B, C); <br/>}< br/>}// END OF THE TERNARY check function.