在 odd/even 问题中,如果我们提供非常大的值(例如最多 12 位数字),那么程序就会出错;
In odd/even question if we provide very large value (like up to 12 digits ) then there are error in program;
在odd/even问题中,如果我们提供非常大的值(比如最多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;
}
在C++中int
可以取的最大值(32位)是2,147,483,647。因此,int
无法处理 12 位数字 - 请改用 long int
或 long long int
。
在odd/even问题中,如果我们提供非常大的值(比如最多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;
}
在C++中int
可以取的最大值(32位)是2,147,483,647。因此,int
无法处理 12 位数字 - 请改用 long int
或 long long int
。