num = numreplace^dig 只能输入0-100数字
The given code is using a regular expression to remove any non-digit characters from the variable "num". However, it does not restrict the input range to only 0-100.
To restrict the input range to only 0-100, you can modify the code as follows:
if (num < 0) {
num = 0;
} else if (num > 100) {
num = 100;
}
This code checks if the value of "num" is less than 0, and if so, sets it to 0. Similarly, if the value of "num" is greater than 100, it sets it to 100. This way, the input range is restricted to 0-100.
原文地址: https://www.cveoy.top/t/topic/jceA 著作权归作者所有。请勿转载和采集!