#include <iostream>
#include<climits>
#include<cstdio>
using namespace std;
bool is_int(long long);
int main()
{
long long theOne;
cout << "EOF means ending"<<endl;
cout << "Please input the test number:"<<endl;
cin >> theOne;
while(theOne!=EOF)
{
if(is_int(theOne))
cout << "YES"<<endl;
else
cout << "Out of range"<<endl;
cin.clear();
cin >>theOne;
}
return 0;
}
bool is_int(long long x)
{
if(x>=INT_MIN&&x<=INT_MAX)
return true;
else
return false;
}
C++ 判断一个数是否在int的取值范围内
最新推荐文章于 2024-04-05 16:30:29 发布
本文介绍了一个简单的C++程序,该程序能够接收用户输入的长整型数值,并判断该数值是否位于标准整型变量的取值范围内。通过使用`INT_MIN`和`INT_MAX`来界定整型的最小和最大值,该程序能有效地进行判断并给出相应的反馈。
3067

被折叠的 条评论
为什么被折叠?



