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;
    }
  • 相关阅读:
    如何实现虚拟机(VirtualBox)中的Ubuntu与Windows XP间的数据共享
    linux中安装sqlmap
    LookupError: unknown encoding: cp65001解决办法
    共勉
    Linux中安装Nginx
    touch: cannot touch `/home/tomcat7/logs/catalina.out': Permission denied
    程序猿的十一条浮躁表现
    MySQL中varchar类型排序
    Gson和FastJson
    jquery-messager-消息提示
  • 原文地址:https://www.cnblogs.com/lyf123456/p/3219189.html
Copyright © 2011-2022 走看看