H-Shen / Collection_of_my_coding_practice

A collection of my coding practice
1 stars 1 forks source link

Macros like the lowerbound/upperbound of an 'int' type is compiler-specific and should be avoid. #7

Closed H-Shen closed 5 years ago

H-Shen commented 5 years ago

In cpp, macros like the lower-bound/upper-bound of an 'int' type is compiler-specific, like LONG_LONG_MIN cannot be used in some compiler since it has LLONG_MIN instead of LONG_LONG_MIN. Such cases should be avoided by using std::numeric_limits<T>.

./Leetcode/155.cpp:        minVal = INT_MAX;
./Leetcode/155.cpp:            minVal = INT_MAX;
./Leetcode/155.cpp:            minVal = INT_MAX;
./Leetcode/155.cpp:    int minVal = INT_MAX;
./Leetcode/53.cpp:            return INT_MIN;
./Hackerrank/Algorithms/Closest_Numbers.cpp:const int MAX = INT_MAX;
./Hackerrank/Algorithms/Minimum_Absolute_Difference_in_an_Array.cpp:    int minVal = INT_MAX;
./校招Collection/Others/最大连续数列和.cpp:        int currentSum = 0, maxSum = 0, interval = INT_MIN;
./校招Collection/2019/旋转数组中的最小元素.cpp:    int minVal = INT_MAX;
./校招Collection/2019/查找第K大的元素.cpp:    int firstMax = INT_MIN;
./校招Collection/2019/查找第K大的元素.cpp:    int secondMax = INT_MIN;
./校招Collection/2019/查找第K大的元素.cpp:    int thirdMax = INT_MIN;
./校招Collection/2019/求连续子数组的最大和.cpp:        return INT_MIN;
./Miscellaneous/fastIO.cpp:    std::uniform_int_distribution<int> dist(INT_MIN, INT_MAX);
./Miscellaneous/fastIO.cpp:    std::uniform_int_distribution<int> dist(INT_MIN, INT_MAX);
./Miscellaneous/heapSort.cpp:    uniform_int_distribution<int> dist(INT_MIN, INT_MAX);
./PAT_Basic_Level_Practice/1012.cpp:    int A5 = INT_MIN;
./PAT_Basic_Level_Practice/1063.cpp:    int pow_max = INT_MIN;
./PAT_Basic_Level_Practice/1045.cpp:    int maxVal = INT_MIN;
./PAT_Basic_Level_Practice/1045.cpp:    int minVal = INT_MAX;
./PAT_Basic_Level_Practice/1047.cpp:    int maxScore = INT_MIN;
./PAT_Basic_Level_Practice/1042.cpp:    int maxVal = INT_MIN;
./PAT_Basic_Level_Practice/1032.cpp:    int maxScore = INT_MIN;
H-Shen commented 5 years ago

FIXED