boj1265

    技术2026-04-13  0

    #include <stdio.h>#include <stdlib.h>#include <string.h>

    int process(char *p){ int num = 0; while(*p != '/0') {  num = 2*num + *p - '0';  p++; } return num;}

    int main(){  int n,count; int i,j,k; char ipaddr[33]; char dst[9];

     scanf("%d",&n); for(i=1;i<=n;i++) {  scanf("%s",ipaddr);

      for(j=0;j<4;j++)  {   count = 0;   for(k=8*j; k< 8*j+8; k++)   {    dst[count++] = ipaddr[k];   }   dst[count] = '/0';

          if(j==3)    printf("%d/n",process(dst));   else    printf("%d.",process(dst));   } }

     return 0;}

     

    最新回复(0)