n&1和n%2等价
n&1和n%2等价但是位运算更快
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n){
cout<<(n&1)<<endl;
cout<<(n%2)<<endl;
}
return 0;
}
n&1和n%2等价但是位运算更快
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n){
cout<<(n&1)<<endl;
cout<<(n%2)<<endl;
}
return 0;
}
相关推荐