POJ 2105

POJ

http://poj.org/problem?id=2105

IP Address

#include <stdio.h>

int main(int argc,char *argv[])
{
int n;
int i;
char bits[33];
int ip;
scanf(
"%d",&n);
while(n--)
{
scanf(
"%s",bits);
ip
= bits[0]%48;
for(i = 1;i<32 ; ++i)
{
if(i%8 == 0){
printf(
"%d.",ip);
ip
= bits[i]%48;
}
else
ip
= 2*ip + bits[i]%48;
}
printf(
"%d\n",ip);
}
return 0;
}

原文地址:https://www.cnblogs.com/westfly/p/2038200.html