• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 183,  comments - 10,  trackbacks - 0

            來自于《編碼》

            布萊葉盲文用六個點組成,位置分別為 1 2 3 4 5 6
            根據六個點是否突起來代表不同的字母,總共有 2 ^ 6 = 64 個情況。

            用一個字節(jié)表示一個編碼,0-5 位分別對應 1-6 個位置。
            例如
            e:
            @.
            .@
            ..
            對應的一個字節(jié)為
            00010001
            即為 17

            編碼表如下,brailleCode.txt:

             1 a    1
             2 b    3
             3 c    9
             4 d    25
             5 e    17
             6 f    11
             7 g    27
             8 h    19
             9 i    10
            10 j    26
            11 k    5
            12 l    7
            13 m    13
            14 n    29
            15 o    21
            16 p    15
            17 q    31
            18 r    23
            19 s    14
            20 t    30
            21 u    37
            22 v    39
            23 w    58
            24 x    45
            25 y    61
            26 z    53
            27 ,    2
            28 ;    6
            29 :    18
            30 .    50
            31 !    22
            32 (    54
            33 )    54
            34 "    38
            35 /    12
            36 #    60
            37 '    4
            38 -    36


            對一句話進行編碼:
            Rizana Nafeek's story is typical of thousands of young women from Sri Lanka and other poor Asian countries who leave their homes in search of employment and better lives for their families in Saudi Arabia and the glittering Gulf states.
            編碼后的結果為:
            @. .@ @. @. @@ @.       @@ @. @@
            @@ @. .@ .. .@ ..       .@ .. @.
            @. .. @@ .. @. ..       @. .. ..

            @. @. @. .. .@  .@ .@ @. @.
            .@ .@ .. .. @.  @. @@ .@ @@
            .. .. @. @. @.  @. @. @. @.

            @@      .@ .@   .@ @@ @@ .@ @@
            .@      @. @.   @@ .@ @. @. ..
            @@      .. @.   @. @@ @. .. ..

            @. @.   @. @@   .@ @. @. @.
            .. @.   .@ @.   @@ @@ .@ ..
            .. @.   @. ..   @. .. @. @@

            .@ @. @@ @@ .@  @. @@   @@
            @. .. .@ .@ @.  .@ @.   .@
            @. .. @. .. @.  @. ..   @@

            @. @. @@ @@     .@ @. @@ @. @@
            .@ .. .@ @@     @@ .@ .. .@ .@
            @. @@ @. ..     .@ @. @. .. @.

                    @@ @. @. @@     .@ @. .@
                    @. @@ .@ ..     @. @@ @.
                    .. @. @. @.     @. @. ..

            @. @. @@ @. @.  @. @@ @@
            @. .. .@ .. ..  .. .@ .@
            @. .. @. @. ..  .. @. ..

            @. .@ @. @. @.  @@ @. @. @.
            .@ @@ @@ .@ @@  @. .@ .@ @@
            @. @. .. .. @.  @. @. @. @.

                    @. .@ .@ @. @@  @@ @. @.
                    .. @. @. .. .@  .. .@ ..
                    .. @. .. .. @.  .. @. @@

            @@ .@ @. .@ @. .@       .@ @. @.
            .@ @@ @@ @. .@ @.       @@ @@ .@
            @. @. @. .. .. @.       .@ .. @.

                    @. @. @. @. @.  .@ @. @.
                    @. .@ .. @. .@  @@ @@ .@
                    @. .. .. @@ ..  @. .. ..

            .@ @.   @. @. @@ @. .@  .@
            @. @@   @@ .@ .. .@ @.  @.
            .. @.   .. @. @. .. @.  ..

            @@      .@ @. @. @. @@ @.       @.
            .@      @. .@ .. @@ .. @@       .@
            @.      @. .. .. @. .. ..       @.

            @@      @. @@ @@ @. @. @@ @@ @.
            @.      .@ .. @. @. .@ .@ .. .@
            ..      .. @. @. @. @. @@ @. ..

            @@ .@   @. @@ @@        @. @. .@
            .@ @@   .. .@ .@        @. .@ @@
            @. @.   .. @. ..        .. .. @.

            .@ @. @.        @. .@ @. @. .@
            @@ .@ @@        @. @. @. .@ @.
            @. .. @.        @. .. @@ .. @.

            @@ @. @.        .@ @. @. .@ @.
            @. .@ @@        @@ @@ .@ @. @@
            .. @. @.        @. .. .. .. @.

            @@ @. @@ .@ @. .@ @. .@         .@
            @. .. .. @. @. @. .@ @.         @.
            .. .. @. .. @. .. .. @.         ..

            @@      .@ @. @. @@ .@  @. @.
            .@      @. .. .. .@ @.  .. @@
            @.      @. .. @@ .. ..  .. @.

            @. @. .@ @.     @. @@ @@        .@
            .. @. @. ..     .. .@ .@        @@
            .. .. .. ..     .. @. ..        @.

            @. @.   @@ @. .@ .@ .@ @. @.
            @@ .@   @@ @. @. @@ @@ .@ @@
            .. ..   .. @. .. @. @. .. @.

            .@ @@ @@        @@ @. @. @@     .@
            @. .@ @@        @@ .. @. @.     @.
            .. @. ..        .. @@ @. ..     @.

            .@ @. .@ @. .@ ..
            @@ .. @@ .@ @. @@
            @. .. @. .. @. .@

            布萊葉盲文是用于盲人讀取的,所謂的解碼即是利用觸覺獲取所蘊含的信息。這種通過觸覺的解碼不宜用計算機來實現。

              1 #include <iostream>
              2 #include <fstream>
              3 #include <string>
              4 #include <map>
              5 #include <cctype>
              6 using namespace std;
              7 
              8 bool test(char c, int i)
              9 {
             10     return (c & (1 << i)) != 0;
             11 }
             12 
             13 void display(const string& bc)
             14 {
             15     for (int i = 0; i < bc.size() / 10 + 1++i)
             16     {
             17         for (string::size_type j = i * 10; j < (i * 10 + 10 < bc.size() ? i * 10 + 10 : bc.size()); ++j)
             18         {
             19             if (bc[j] == ' ')
             20             {
             21                 cout << '\t';
             22             }
             23             else
             24             {
             25                 if (test(bc[j], 0))
             26                 {
             27                     cout << '@';
             28                 }
             29                 else
             30                 {
             31                     cout << '.';
             32                 }
             33                 if (test(bc[j], 3))
             34                 {
             35                     cout << '@';
             36                 }
             37                 else
             38                 {
             39                     cout << '.';
             40                 }
             41                 cout << ' ';
             42             }
             43         }
             44         cout << endl;
             45         for (string::size_type j = i * 10; j < (i * 10 + 10 < bc.size() ? i * 10 + 10 : bc.size()); ++j)
             46         {
             47             if (bc[j] == ' ')
             48             {
             49                 cout << '\t';
             50             }
             51             else
             52             {
             53                 if (test(bc[j], 1))
             54                 {
             55                     cout << '@';
             56                 }
             57                 else
             58                 {
             59                     cout << '.';
             60                 }
             61                 if (test(bc[j], 4))
             62                 {
             63                     cout << '@';
             64                 }
             65                 else
             66                 {
             67                     cout << '.';
             68                 }
             69                 cout << ' ';
             70             }
             71         }
             72         cout << endl;
             73         for (string::size_type j = i * 10; j < (i * 10 + 10 < bc.size() ? i * 10 + 10 : bc.size()); ++j)
             74         {
             75             if (bc[j] == ' ')
             76             {
             77                 cout << '\t';
             78             }
             79             else
             80             {
             81                 if (test(bc[j], 2))
             82                 {
             83                     cout << '@';
             84                 }
             85                 else
             86                 {
             87                     cout << '.';
             88                 }
             89                 if (test(bc[j], 5))
             90                 {
             91                     cout << '@';
             92                 }
             93                 else
             94                 {
             95                     cout << '.';
             96                 }
             97                 cout << ' ';
             98             }
             99         }
            100         cout << endl;
            101         cout << endl;
            102     }
            103 }
            104 
            105 string encode(const string& sentence, const map<charint> encoding)
            106 {
            107     string tmp;
            108     for (string::size_type i = 0; i != sentence.size(); ++i)
            109     {
            110         map<charint>::const_iterator cit = encoding.find(tolower(sentence[i]));
            111         if (cit != encoding.end())
            112         {
            113             tmp += static_cast<char>(cit->second);
            114         }
            115         else
            116         {
            117             tmp += ' ';
            118         }
            119     }
            120     return tmp;
            121 }
            122 
            123 int main()
            124 {
            125     ifstream fin("brailleCode.txt");
            126     if (!fin)
            127     {
            128         cerr << "File error!" << endl;
            129         return 1;
            130     }
            131     map<charint> encoding;
            132     char a;
            133     int b;
            134     while (fin >> a >> b)
            135     {
            136         encoding[a] = b;
            137     }
            138     string sentence, bc;
            139     while (getline(cin, sentence))
            140     {
            141         bc = encode(sentence, encoding);
            142         //cout << bc << endl;
            143         display(bc);
            144     }
            145     return 0;
            146 }

             

             


            posted on 2011-11-15 18:20 unixfy 閱讀(383) 評論(0)  編輯 收藏 引用
            69国产成人综合久久精品| 人人狠狠综合88综合久久| 久久精品国产99久久久香蕉| 久久精品人人做人人爽电影蜜月| 亚洲?V乱码久久精品蜜桃| 久久精品国产72国产精福利| AV无码久久久久不卡蜜桃| 精品伊人久久大线蕉色首页| 久久中文字幕人妻丝袜| 久久婷婷国产剧情内射白浆 | 国产精品美女久久久久AV福利| 久久精品午夜一区二区福利| 99精品久久精品一区二区| 亚洲精品国精品久久99热一| 人妻少妇久久中文字幕一区二区| 一本久久a久久精品vr综合| 亚洲人成网亚洲欧洲无码久久| 狠狠色丁香婷婷久久综合五月| 99精品国产综合久久久久五月天| 无码人妻久久久一区二区三区| 奇米综合四色77777久久| 久久er热视频在这里精品| 蜜桃麻豆www久久| 国产精品久久久久免费a∨| 亚洲精品无码久久久久| 99麻豆久久久国产精品免费| 国产精品成人久久久久久久| 欧美久久久久久| 久久精品草草草| 99久久香蕉国产线看观香| 久久久噜噜噜www成人网| 国产午夜福利精品久久| 国产69精品久久久久9999APGF| 久久香综合精品久久伊人| 狠狠人妻久久久久久综合蜜桃 | 久久成人18免费网站| 免费精品久久天干天干| 久久99精品国产99久久6| 日本久久久久亚洲中字幕 | 国产精品久久久久久久午夜片 | 国产精品日韩深夜福利久久 |