怎么实现 将 二进制与字符串的互相转换,C,C++,Java实现都可以。

例如:输入 110001000010001 111001000110001 101110000001111 1001110001111100

输出 我叫小明

      输入  我叫小明
      输出  110001000010001 111001000110001 101110000001111 100111000111110

http://blog.csdn.net/tangxufeng/article/details/4288106

 /* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        String s = "0110001000010001";
        char c = 0;
        for (int i = 0; i < 16; i++)
        {
            c *= 2;
            if (s.charAt(i) == '1') c += 1;
        }
        System.out.println(c);
    }
}

http://ideone.com/5vCxZx

在线编译通过