• <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>

            DraculaW

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              19 隨筆 :: 0 文章 :: 7 評(píng)論 :: 0 Trackbacks

            2008年11月28日 #

                 摘要: 我嘗試寫(xiě)的一個(gè)智能指針
            希望大家能幫我提一些意見(jiàn) 謝謝

            上面是測(cè)試碼
            下面是代碼  閱讀全文
            posted @ 2008-11-28 17:39 DraculaW 閱讀(399) | 評(píng)論 (0)編輯 收藏

            2007年11月22日 #

                 摘要: 紅黑樹(shù)的插入算法的描述 不知道清楚么 希望大家指正  閱讀全文
            posted @ 2007-11-22 20:47 DraculaW 閱讀(313) | 評(píng)論 (0)編輯 收藏

            2007年11月21日 #

                 摘要: 對(duì)內(nèi)存分配算法的一點(diǎn)想法 希望大家指正  閱讀全文
            posted @ 2007-11-21 22:38 DraculaW 閱讀(1955) | 評(píng)論 (1)編輯 收藏

            2007年11月20日 #

                 摘要: 大概的介紹了下deque的實(shí)現(xiàn)
            為什么要用這種實(shí)現(xiàn)方式 誰(shuí)能解釋一下  閱讀全文
            posted @ 2007-11-20 22:30 DraculaW 閱讀(1159) | 評(píng)論 (0)編輯 收藏

            2007年11月15日 #

            template<typename T, typename U>
            class Conversion
            {
                typedef char Small;
                class Big{char dummy[2];};
                static Small Test(U)    {   }  
                static Big Test(...) { }  
                static T MakeT() { }
               
            public:
                enum { exists = sizeof(Test(MakeT())) == sizeof(Small)};   
            };

            如果T可以轉(zhuǎn)換為U 于是就調(diào)用Test(U)這個(gè)函數(shù) 返回一個(gè)char;
            如果不能 就調(diào)用使用(...)缺省參數(shù)的函數(shù) 返回一個(gè)數(shù)組

            然后對(duì)返回值進(jìn)行判斷....
            posted @ 2007-11-15 20:45 DraculaW 閱讀(270) | 評(píng)論 (0)編輯 收藏

                 摘要: STL與boost的type traits  閱讀全文
            posted @ 2007-11-15 20:43 DraculaW 閱讀(935) | 評(píng)論 (0)編輯 收藏

            # The readfpl accept a file's path while is fpl(foobar play list),
            # and return a list which holds all the file'path
            sub readfpl
            {
                my @files;
                my @chunks;
                my $index = 0;

                open(INPUT, "< $_[0]")
                    or die "can't open";

                @chunks = split(m{file://}, <INPUT>);

                foreach(@chunks)
                {   
                    if($_ =~ m/.+\.(mp3|wma|m4a)/)
                    {
                        $files[$index] = $&;
                        $index ++;
                    }
                }

                print $files[0];
               
                return @files;
            }

            my @files = readfpl($ARGV[0]);
            my $string;

            foreach(@files){
                 $string = $_;
                    # the next while get name from path
                 while( substr($string, 1) =~ m{\\.+\.(mp3|wna|m4a)}) {
                     $string = $ARGV[0].$&;
                     }
                 rename $_, string;
            }

            將這段代碼存為movefpl.pl然后在命令行打入 movefpl.pl 播放列表的全路徑 要存歌曲的新路徑
            就可以了呢 呵呵
            posted @ 2007-11-15 20:41 DraculaW 閱讀(296) | 評(píng)論 (0)編輯 收藏

            Assessing Infection

            Background

            According to the World Health Organization, infectious disease ranks as the leading cause of death in the world. In 1998 alone, over 17 million people died from infectious and parasitic diseases such as acute lower respiratory infections, tuberculosis, HIV/AIDS, and malaria. It is forecast that infectious disease will continue to kill millions of people, especially those living in developing countries.

            The medical profession and scientific community of the world are fighting the infectious disease threat with new tools and technologies from a variety of fields. From this effort, a new field of research has emerged. Infectious Disease Epidemiology is the study of the variables that influence the growth and spread of infectious diseases. This relatively new field combines molecular biology, immunology, genetics, and the computational sciences. A focus of this field is the study of the factors that influence the growth of an infectious disease within a single organism, and the factors that influence the pattern of infection across an entire population.

            Description

            This assignment asks you to finish the implementation of a program that assesses the level of infection in a tissue sample. You are given data representing a rectangular tissue sample, overlaid with a grid. Certain portions of the tissue are infected; others are not. Your goal is to help assess the extent of the infection by writing a program that, given the coordinates of a colony of infection, can determine its size.

            A typical use of the program follows. The user interacts with the program only through command-line arguments. The user supplies to the program a data filename and the coordinates of a cell in the grid. The coordinates are specified by row and then column, both starting at zero. The program calculates the extent of infection at that coordinate and outputs a two-dimensional representation of the tissue sample. Figure 1 depicts the execution of the program.

            A screen shot from a sample solution
            Figure 1 Output from a sample solution

            For the purpose of this assessment, we consider a "colony" of infected tissue to be a set of adjacent and infected cells. In Figure 1, we can see three separate colonies. The smallest colony consists of two cells and is located in the lower left corner of the grid. Another colony consisting of three infected cells exists on the far right edge of the grid. The largest colony of eight cells resides primarily in the middle of the grid. This colony has a small arm into the upper left corner of the grid. Notice from this colony that cells residing in diagonals are considered "adjacent." The plus signs next to the cells in this largest colony indicate that they all belong to the colony that contains the user entered coordinate.


            solution :

            #ifndef GRID_H
            #define GRID_H

            #include <string>
            #include <vector>

            using namespace std;

            /*
            * IMPORTANT NOTE:
            *
            * For this assignment, you might need to add state to the
            * class and/or augment existing methods, and/or create private helper
            * methods, but you should not delare new public methods
            */

            const bool INFECTED = true;
            const bool NOT_INFECTED = false;

            class grid;

            class grid {

            private:
                int rows;
                int cols;
                vector<bool> *area;
                vector<bool> *infect;
                int indexof (int row, int col) const;
                bool infected(int row, int col) const;

            public:
                grid (string file);
                ~grid ();

                int count (int row, int col);

                friend ostream &operator<<(ostream &stream, const grid& ob);

            };

            #endif

            ============================================================================

            #include <iostream>
            #include <fstream>

            using namespace std;

            #include "grid.h"

            // You do not need to alter function indexof.
            int grid::indexof (int row, int col) const {
                return row*cols+col;
            }

            // You do not need to alter function infected.
            bool grid::infected(int row, int col) const {
                return (area->operator[](indexof(row, col)) == INFECTED);
            }

            // You may need to alter the constructor
            grid::grid (string file) {

                ifstream grid_file;

                grid_file.open (file.c_str());

                grid_file >> rows;
                grid_file >> cols;

                area = new vector<bool>(rows*cols, NOT_INFECTED);
                infect = new vector<bool>(rows*cols, NOT_INFECTED);
               
                while (true) {

                    int blob_row;
                    int blob_col;

                    grid_file >> blob_row;
                    grid_file >> blob_col;

                    if (grid_file.eof()) {
                        break;
                    }

                    area->operator[](indexof(blob_row,blob_col)) = INFECTED;
                }

                grid_file.close();
            }

            // You may need to alter the destructor
            grid::~grid () {
                delete area;
                delete infect;
            }

            // You will need to alter this function to display the
            // plus signs (+) next to the cells that belong to
            // a counted colony.
            ostream &operator<<(ostream &stream, const grid& ob) {

                for (int row=0; row < ob.rows; row++) {
               
                    for (int col=0; col < ob.cols; col++) {

                        stream << ob.area->operator[](ob.indexof(row, col));
                        if( ob.infect->operator[] ( ob.indexof(row, col) ) )
                            stream << "+ ";
                        else
                            stream << "   ";
                    }

                    stream << endl;
                }

                stream << endl;
                return stream;
            }

            // Replace the return statement in this function with your
            // recursive implementation of this method */
            int grid::count (int row, int col) {

                if( row < 0 || col < 0 || row == rows || col == cols)
                    return 0;

                if( area->operator[](indexof(row,col) ) == NOT_INFECTED )
                    return 0;

                if(infect->operator[](indexof(row,col)) == INFECTED)
                    return 0;

                infect->operator[](indexof(row,col)) = INFECTED;

                // Recursive test the 8 point near the point
                // which area is INEFCTED and infect is NOT_INFECTED

                return    count( row - 1, col - 1 ) + count ( row - 1, col )
                    + count( row - 1, col + 1 ) + count( row, col - 1 )
                    + count( row, col ) + 1 + count( row, col + 1 )
                    + count( row + 1, col - 1 ) + count( row + 1, col )
                    + count( row + 1, col + 1 );
            }
            posted @ 2007-11-15 20:40 DraculaW 閱讀(484) | 評(píng)論 (0)編輯 收藏

                 摘要: 一道簡(jiǎn)單的作業(yè)貼 呵呵   閱讀全文
            posted @ 2007-11-15 20:39 DraculaW 閱讀(446) | 評(píng)論 (0)編輯 收藏

            手機(jī)的英文智能輸入法其實(shí)很簡(jiǎn)單的想法 使用哈希來(lái)實(shí)現(xiàn) 呵呵

            1       2       3
            ,.    abc    def

            4       5       6
            ghi    jkl    mno

            7       8       9
            pqrs tuv   wxyz

            譬如說(shuō)輸入 43
            進(jìn)入這個(gè)哈希里面去尋找
            key[43] -> [if] -> [he] -> [id] -> [ie]-> [ge] -> [gf] -> 0
            還可以輸入更多的 呵呵。

            以此類(lèi)推,如果是拼音輸入也是一樣,只不過(guò)要多進(jìn)行一次哈希。從拼音哈希到具體的漢字里面去。

            不過(guò)拼音輸入的狀態(tài)機(jī)應(yīng)該更復(fù)雜一些。因?yàn)槠匆糨斎肟梢愿鶕?jù)前一個(gè)字來(lái)推斷可能出現(xiàn)的下一個(gè)字。

            其實(shí) 不只是手機(jī),只要是使用數(shù)字鍵盤(pán)的機(jī)器都可以使用這樣子的輸入法。

            使用這種算法的變種還可以實(shí)現(xiàn)一個(gè)好玩的游戲:就是輸入一個(gè)單詞,然后輸出所有與它組成元素相同的單詞(就是輸入stop 它可以輸出tops等單詞)。具體也是使用哈希。哈希真是一個(gè)好算法
            posted @ 2007-11-15 20:37 DraculaW 閱讀(328) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題  下一頁(yè)
            久久中文字幕无码专区| 久久久久人妻一区精品色| 人人狠狠综合久久88成人| 久久一区二区三区免费| 中文字幕亚洲综合久久2| av国内精品久久久久影院| 蜜臀av性久久久久蜜臀aⅴ麻豆| 久久精品国产亚洲av麻豆蜜芽| 久久人人爽人人爽人人片AV不| 思思久久99热只有频精品66| 久久午夜综合久久| 色播久久人人爽人人爽人人片aV| 久久播电影网| 国产精品久久婷婷六月丁香| 久久亚洲AV无码精品色午夜麻豆| 日本五月天婷久久网站| 亚洲中文精品久久久久久不卡| 精品久久人妻av中文字幕| 久久99热国产这有精品| 久久久国产精华液| 人人妻久久人人澡人人爽人人精品| 久久久国产打桩机| 99久久国产综合精品麻豆| 中文精品久久久久国产网址| 香蕉久久影院| 精品国际久久久久999波多野| 91久久精品国产91性色也| 日韩中文久久| 97久久香蕉国产线看观看| 久久久久久无码国产精品中文字幕| 亚洲午夜精品久久久久久app| 无码人妻少妇久久中文字幕蜜桃| 99久久综合国产精品二区| 精品人妻伦九区久久AAA片69| 国产精品毛片久久久久久久| 久久天天躁狠狠躁夜夜不卡| 久久久久亚洲Av无码专| 色综合合久久天天给综看| 久久国产亚洲精品麻豆| 精品国产99久久久久久麻豆| 国产伊人久久|