【十二题解】 | #整数与IP地址间的转换#
整数与IP地址间的转换
http://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
#include<stdio.h>
int main(){
int ip[4]={0};
scanf("%d.%d.%d.%d", &ip[0], &ip[1],&ip[2],&ip[3]);
long long data=0;
for(int i=0; i<4; i++){
int aa = ip[i];
data<<=8;
data+=ip[i];
}
long long data2=0;
scanf("%d", &data2);
int a, b, c, d;
d=data2%256;
data2>>=8;
c=data2%256;
data2>>=8;
b=data2%256;
data2>>=8;
a=data2;
printf("%ld\n%d.%d.%d.%d", data, a, b, c, d);
}