题解 | #整数与IP地址间的转换#
整数与IP地址间的转换
https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea
#include <iostream> using namespace std; int main() { string str; long a, b, c, d; scanf("%d.%d.%d.%d", &a, &b, &c, &d); cout << ((a << 24) + (b << 16) + (c << 8) + d) << endl; long num; cin >> num; a = num >> 24; num -= a << 24; b = num >> 16; num -= b<< 16; c = num >> 8; num -= c << 8; d = num; cout << a << "." << b << "." << c << "." << d << endl; } // 64 位输出请用 printf("%lld")