gpt4 book ai didi

C 编程 : How can I check if given number is exactly for digits, 不多/不少?

转载 作者:行者123 更新时间:2023-11-30 21:43:45 24 4
gpt4 key购买 nike

C 编程:如何检查给定的数字是否恰好为数字,不多/不多?

我对 C 编程还是新手。抱歉,如果这是一个容易问的问题。

最佳答案

只需检查数字的范围:

int x = 4125; //this is just an example value ...
if( (x >= 1000 && x <= 9999) || (x >= -9999 && x <= -1000) ){
//is valid
}else{
//is not valid
}

关于C 编程 : How can I check if given number is exactly for digits, 不多/不少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33671600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com