zoukankan      html  css  js  c++  java
  • 2105 IP Address

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    int main()
    {
     

          int n;
           scanf("%d",&n);
           int a[80],b[80],c[80],d[80];
           char str[200];
           while(n--)
           {
                memset(a,0,sizeof(a));
                 memset(b,0,sizeof(b));
                    memset(c,0,sizeof(c));
                      memset(d,0,sizeof(d));
                     memset(str,0,sizeof(str));
                 scanf("%s",str);
                int i,j,t1=0,t2=0,t3=0,t4=0;
               for(j=0;j<8;j++)
                {
                    a[j]=str[j]-'0';
                    if(a[j]==1)
                    {
                        t4+=(int)pow(2,7-j);
                    }
                }
               for(j=8;j<16;j++)
                {
                    b[j]=str[j]-'0';
                    if(b[j]==1)
                    {
                        t3+=(int)pow(2,15-j);
                    }
                }
                for(j=16;j<24;j++)
                {
                    c[j]=str[j]-'0';
                    if(c[j]==1)
                    {
                        t2+=(int)pow(2,23-j);
                    }
                }
                for(j=24;j<32;j++)
                {
                    d[j]=str[j]-'0';
                    if(d[j]==1)
                    {
                        t1+=(int)pow(2,31-j);
                    }
                }
               printf("%d%c%d%c%d%c%d",t4,'.',t3,'.',t2,'.',t1);
               printf(" ");
           }
           return 0;
    }
  • 相关阅读:
    rtmp 之 amf
    Codeforces Round #601 (Div. 1)
    Codeforces Round #618 (Div. 1)
    Codeforces Round #694 (Div. 1) BCDE
    AtCoder Regular Contest 106 DEF
    AtCoder Grand Contest 006 BCDEFF
    JavaScript中深拷贝的实现方法
    suiidfadf
    macOs打开时提示:xxx.app已损坏修复教程
    vue通过事件对象获取标签上的属性值
  • 原文地址:https://www.cnblogs.com/lyf123456/p/3219189.html
Copyright © 2011-2022 走看看