View Code of Problem 1188

/*
*/
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int f(string s){
    int ans=0;
    for(int i=0;i<8;i++){
        ans=ans*2+s[i]-'0';
    }
    return ans;

}


int main(){
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        int num[4]={0,0,0,0};
        int i=0;
        while(i<=3) {
            string temp = s.substr(0 + i * 8, 8 );
            num[i] = f(temp);
            i++;
        }

        for(int i=0;i<4;i++){
            printf("%d",num[i]);
            if(i!=3){
                printf(".");
            }
        }
        printf("\n");

    }

}

Double click to view unformatted code.


Back to problem 1188