码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 2105

时间:2015-06-10 19:16:02      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    //freopen("acm.acm","r",stdin);
    int num;
    int i;
    int j;
    int tem;
    int index;
    int sum;
    string s;
    cin>>num;
    getchar();
    while(num --)
    {
        index = 0;
        getline(cin,s);
        for(i = 0; i < 4; ++ i)
        {
            sum = 0;
            for(j = index; j < 8+index; ++ j)
            {
                tem = s[j] - 0;
                if(tem == 1)
                    sum += pow(double(2),index+8-j-1)*tem;
            }
            index += 8;
            if(i != 3)
                cout<<sum<<".";
            else 
                cout<<sum;
        //    cout<<"    index "<<index<<endl;
        }
        cout<<endl;
    }
}

 

POJ 2105

标签:

原文地址:http://www.cnblogs.com/gavinsp/p/4566655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!