Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"math"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	two := make([]float64, 12)
	flag := make([]int, 12)
	for i := 0; i < 12; i++ {
		two[i] = math.Pow(2.0, 7.0-float64(i))
	}
	for scanner.Scan() {
		n, _ := strconv.ParseFloat(scanner.Text(), 64)
		if n < 0 {
			break
		}
		for i := 0; i < 12; i++ {
			flag[i] = 0
			if n >= two[i] {
				n -= two[i]
				flag[i] = 1
			}
		}
		if n < 10e-10 {
			i := 0
			for i < 12 {
				fmt.Printf("%d", flag[i])
				if i == 7 {
					fmt.Printf(".")
				}
				i++
			}
			fmt.Printf("\n")
		} else {
			fmt.Println("NA")
		}
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
    double n,m;
    int a = 0;
    int res = 0;
    int bai = 1;
    double ans = 0,ahokusa = 0;
    while(cin >> n)
    {
        if(n == -1.0)return 0;
        while(1)
        {
            a = n;
            m = n - a;
            if(a > 256 || m < 0.0625)
            {
                puts("NA");
            }
            else
            {
                while(a > 0)
                {
                    res += (a%2)*bai;
                    a /= 2;
                    bai *= 10;
                }
            }
            ans += res;
            int asukoge = 0;
            for(int i = 1; i < 5; i++)
            {
                if(m == 1/pow(2,i))ahokusa += pow(0.1,i);
                if(i == 16 && ahokusa == 0)
                {
                    puts("NA");
                    break;
                }
            }
            printf("%013.4f\n",ans+ahokusa);
            break;
        }
    }

    return 0;
}

C++: #include<cstdio>
double ni(int n){
    double ret=1.0;
    if(n>=0){
        for(int i=0;i<n;i++){
            ret*=2;
        }
    }else{
        for(int i=0;i>n;i--){
            ret/=2;
        }
    }
    return ret;
}
int main(){
    double ins;
    for(;;){
        scanf("%lf",&ins);
        if(ins<0) break;
        int ar[12];
        for(int i=7;i>=-4;i--){
            double r=ni(i);
            if(ins>=r){
                ar[i+4]=1;
                ins-=r;
            }else{
                ar[i+4]=0;
            }
        }
        if(ins==0){
            for(int i=7;i>=0;i--){
                printf("%d",ar[i+4]);
            }
            printf(".");
            for(int i=-1;i>=-4;i--){
                printf("%d",ar[i+4]);
            }
            printf("\n");
        }else printf("NA\n");
    }
}

C++: #include<iostream>
#include<string>
using namespace std;

double pow(int a){
  double res = 1;
  for (int i = 0; i < a; i++) {
    res /= 2;
  }
  return res;
}

int main(int argc, char *argv[]){
  double d;
  while (std::cin >> d) {
    if(d < 0)break;
    int digit = 8;
    string ans;
    for (int i = digit; i >= 0; i--) {
      if(d >= (1<<i)){
        ans = ans + '1';
        d -= (1<<i);
      }else{
        ans = ans + '0';
      }
    }
    ans = ans + ".";
    for (int i = 0; i < 4; i++) {
      if(d >= pow(i)){
        ans = ans + '1';
        d -= pow(i);
      }else{
        ans = ans + '0';
      }      
    }
    if(d == 0)std::cout << ans << std::endl;
    else std::cout << "NA" << std::endl;
  }
  return 0;
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;

const int INF=1000000;
char field[101][101];
int d[101][101];
int N,M;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX_N=1000;

int main(){
	
	double s;
	while(cin>>s,s>0){
		string a="";
		bool f=false;
		if(s<256){
			for(int i=7;i>=-4;i--){
				if(s-pow(2,i)>=0){
					s-=pow(2,i);
					a+='1';
				}
				else
					a+='0';
				if(i==0)
					a+='.';
			}
			if(s==0)
				f=true;
			
		}
		if(f)
			cout<<a<<endl;
		else
			cout<<"NA"<<endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"



string to_string_keta(const long long int l, const int keta) {
	ostringstream oss;

	oss << std::setw(keta) << std::setfill('0') << l;

	return oss.str();
}
int main() {
	while (1) {
		string st; cin >> st;
		if (st[0] == '-')break;
		string up = st.substr(0, st.find('.'));
		string down = st.substr(st.find('.') + 1);
		if (stoi(up)< 0)break;
		else {
			int ap = stoi(up);
			if (ap >= powint(2, 8)) {
				cout << "NA" << endl;
				continue;
			}
			else {
				string ans;
				for (int i = 7; i >= 0; --i) {
					if (ap >= powint(2, i)) {
						ans.push_back('1');
						ap -= powint(2, i);
					}
					else {
						ans.push_back('0');
					}
				}
				ans.push_back('.');
				bool ok = false;
				for (int i = 0; i <= 15; ++i) {
					int ast = 625 * i;
					string aast = to_string_keta(ast, 4);
					while (!aast.empty()&&aast.back() == '0') aast.pop_back();
					if (aast.empty())aast = "0";
					if (aast == down) {
						ok = true;
						int num = i;
						for (int j = 3; j >=0; --j) {
							if (num >= powint(2, j)) {
								ans.push_back('1');
								num -= powint(2, j);
							}
							else {
								ans.push_back('0');
							}
						}
					}
				}
				if (!ok) {
					cout << "NA" << endl;
					continue;
				}
				else {
					cout << ans << endl;
				}
			}
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  double d;
  int a[12];
  int i;
  while(cin>>d,d>=0){
    if(d>=256.0){
      puts("NA");
      continue;
    }
    for(i=0;i<7;i++)d/=2.0;
    for(i=0;i<12;i++){
      a[i]=0;
      if(d>=1){a[i]++;d--;}
      d*=2;
    }
    if(d){
      puts("NA");
    }else{
      for(i=0;i<12;i++){
	if(i==8)cout<<".";
	cout<<a[i];
      }
      cout<<endl;
    }
  }
}

C++: #include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <vector>
#include <limits>

constexpr auto INF = std::numeric_limits<int>::max();

using Pair = std::pair<int, int>;

int n, m;
Pair size[210];
int dp[210];

int main() {
    while(std::cin >> n, n) {
        for(int i = 0; i < n; ++i) {
            std::cin >> size[i].first >> size[i].second;

            size[i].second *= -1;
        }
        std::cin >> m;
        for(int i = 0; i < m; ++i) {
            std::cin >> size[n + i].first >> size[n + i].second;

            size[n + i].second *= -1;
        }

        std::sort(size, size + n + m);
        std::fill(dp, dp + 210, INF);

        int max = 0;
        for(int i = 0; i < n + m; ++i) {
            size[i].second *= -1;

            auto p = std::lower_bound(dp, dp + 210, size[i].second);

            *p = size[i].second;

            max = std::max<int>(max, p - dp);
        }

        std::cout << max + 1 << std::endl;
    }
}