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;
    }
  • 相关阅读:
    网页素材收集
    【转】你离顶尖 Java 程序员,只差这11本书的距离
    Jetbrains 破解 2017
    WebStorm的常用操作
    浅谈MySQL主从复制
    Lombok注解指南
    【我的《冒号课堂》学习笔记】设计模式(3)行为模式
    【我的《冒号课堂》学习笔记】设计模式(2)结构模式
    【我的《冒号课堂》学习笔记】设计模式(1)创建模式
    【我的《冒号课堂》学习笔记】设计原则(4)保变原则
  • 原文地址:https://www.cnblogs.com/lyf123456/p/3219189.html
Copyright © 2011-2022 走看看