OpenJudge NOI 刷题日常(1)
1.4 05:整数大小比较
该题注意事项:
整数范围为“0 <= x < 2^32, -2^31 <= y < 2^31”,
而int型范围为-2^31~2^31-1,所以应该使用long long型或unsigned int型。
PS:对于x,可使用unsigned int型。
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long x=0,y=0;
scanf("%lld %lld",&x,&y);
if(x>y){
printf("%s",">");
}
else if(x<y){
printf("%s","<");
}
else
{
printf("%s","=");
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
unsigned int x=0;
long long y=0;
scanf("%lld %lld",&x,&y);
if(x>y){
printf("%s",">");
}
else if(x<y){
printf("%s","<");
}
else
{
printf("%s","=");
}
return 0;
}

浙公网安备 33010602011771号