HJ33 整数与IP地址间的转换
作者:互联网
HJ33 整数与IP地址间的转换
位运算
题目
代码
#include <iostream>
using namespace std;
//位运算
int main(){
long long int a, b, c, d, num;
while(scanf("%lld.%lld.%lld.%lld",&a, &b, &c, &d) != EOF){
cin>>num;
cout<< (a<<24) + (b<<16) + (c<<8) + d<<endl;
a = num>>24;
num = num - (a<<24);
b = num>>16;
num = num - (b<<16);
c = num>>8;
num = num - (c<<8);
d = num;
cout<<a<<"."<<b<<"."<<c<<"."<<d<<endl;
}
return 0;
}
标签:int,.%,整数,num,long,IP地址,HJ33,lld 来源: https://blog.csdn.net/qq_42250642/article/details/123596486