在奇数/偶数问题中,如果我们提供了非常大的值(比如最多12位数字),那么程序中就有错误



在奇数/偶数问题中,如果我们提供了非常大的值(最多12位(,则程序中存在错误;

#include<iostream>
using namespace std;
int main(){
cout<<"This program is for finding if the provided integer is even or odd.nPls provide the integer...n";
int a;
cin>>a;
if(a%2==0){
cout<<"The provided integer is even.";
}
else{
cout<<"The provided integer is odd.";
}
return 0;
}

int在C++中可以接受的最大值(32位(为2147483647。因此,12位数字不能由int处理——请使用long intlong long int

最新更新