青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

DraculaW

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  19 隨筆 :: 0 文章 :: 7 評論 :: 0 Trackbacks
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 on 2007-11-15 20:40 DraculaW 閱讀(502) 評論(0)  編輯 收藏 引用
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            在线一区日本视频| 亚洲伦理在线| 久久精品亚洲一区二区三区浴池| 亚洲午夜在线观看| 久久av资源网站| 欧美激情四色| 午夜精品久久| 能在线观看的日韩av| 欧美日韩精品免费 | 欧美国产日韩一区二区三区| 免费成人在线视频网站| 国产乱码精品一区二区三区五月婷 | 你懂的国产精品| 一区二区三区日韩在线观看| 久久精品国语| 国产精品亚洲美女av网站| 亚洲日本在线观看| 久久久亚洲欧洲日产国码αv | 免费日韩视频| 久久成人av少妇免费| 欧美色欧美亚洲高清在线视频| 黑丝一区二区三区| 亚洲综合日韩在线| 日韩视频在线观看免费| 欧美va天堂va视频va在线| 亚洲一区二区三区三| 久久精品人人爽| 亚洲一区日本| 免费一级欧美片在线观看| 国产精品99久久久久久久久久久久 | 国产日韩精品一区二区| 这里只有视频精品| 欧美一区二区久久久| 国产精品久久久久99| 国产精品99久久久久久人| 久久国产成人| 午夜日韩视频| 亚洲曰本av电影| 国产精品亚洲综合天堂夜夜| 亚洲高清在线观看一区| 在线综合视频| 久久久视频精品| 激情文学一区| 欧美大尺度在线观看| 免费精品视频| 久久伊人一区二区| 免费久久99精品国产| 久久福利毛片| 国产免费成人| 99精品免费| 国产婷婷色一区二区三区| 久久国产欧美日韩精品| 久久精品av麻豆的观看方式| 亚洲欧美成人| 久久激情一区| 久久精品国产77777蜜臀| 国产精品乱子久久久久| 久久久久久久综合| 国产婷婷一区二区| 亚洲一区二区视频在线| 午夜精品www| 国产伦精品一区二区三区四区免费 | 国产日韩精品一区二区三区 | 久久永久免费| 黑丝一区二区| 久久久亚洲国产美女国产盗摄| 久久久精品国产免大香伊| 国产视频精品va久久久久久| 午夜亚洲福利| 91久久精品一区二区三区| 亚洲人成网站在线播| 国产精品第一页第二页第三页| 一片黄亚洲嫩模| 亚洲一区三区电影在线观看| 国产精品久久一级| 性欧美超级视频| 噜噜噜躁狠狠躁狠狠精品视频| 欧美日韩在线观看一区二区| 久久欧美中文字幕| 亚洲国产一成人久久精品| 一区二区三区日韩精品| 欧美亚洲综合网| 欧美午夜一区二区| 亚洲国产一区在线观看| 国产午夜久久| 美日韩精品免费观看视频| 亚洲国产日韩欧美| 亚洲欧美卡通另类91av| 黄色亚洲精品| 欧美日韩精品一二三区| 亚洲欧美在线一区| 亚洲国产成人在线播放| 亚洲欧美日韩精品久久久| 狠狠色狠狠色综合| 欧美日韩免费观看一区二区三区| 亚洲欧美精品suv| 亚洲自拍偷拍麻豆| 在线观看日韩一区| 久久riav二区三区| 久久成人一区二区| 亚洲人成网站在线观看播放| 国产精品专区h在线观看| 久久亚洲综合色| 久久久夜夜夜| 亚洲一区二区三区视频播放| 黑人一区二区三区四区五区| 国产精品www网站| 美女视频一区免费观看| 午夜在线观看欧美| 日韩视频免费观看| 麻豆久久婷婷| 性欧美长视频| 一区二区冒白浆视频| 亚洲大片精品永久免费| 久热精品在线视频| 欧美成人免费在线视频| 欧美一区二区在线视频| 国产欧美日韩免费| 欧美日韩天天操| 久久综合久久综合九色| 欧美一区二区三区四区在线观看| 亚洲精品美女91| 欧美二区在线播放| 久久色中文字幕| 欧美在线观看一区| 亚洲一区二区三区在线观看视频| 亚洲精品国产精品久久清纯直播| 国产在线日韩| 欧美韩日精品| 日韩视频在线免费观看| 欧美国产亚洲精品久久久8v| 久久夜色精品国产欧美乱极品| 午夜精品视频在线观看一区二区 | 国产精品久久久久久久久久免费看 | 欧美日韩在线三级| 欧美精品久久一区| 一区二区高清视频在线观看| 亚洲国产欧美国产综合一区| 欧美成人第一页| 久久综合狠狠综合久久激情| 久久精品国产亚洲一区二区| 欧美一级久久| 久久精品123| 久久精品日产第一区二区| 久久精品亚洲一区二区三区浴池 | 最新日韩精品| 在线视频你懂得一区| 在线综合视频| 欧美一区二区三区视频在线观看 | 亚洲精品网址在线观看| 99国产精品久久久久老师| 国产精品成人一区二区网站软件 | 久热re这里精品视频在线6| 美女主播精品视频一二三四| 欧美国产激情| 亚洲精品免费电影| 在线一区二区三区做爰视频网站| 久久久噜噜噜久久中文字幕色伊伊 | 久久精品人人做人人综合| 久久另类ts人妖一区二区| 美女图片一区二区| 91久久国产精品91久久性色| 久久免费精品日本久久中文字幕| 久久婷婷激情| 亚洲东热激情| 中文av一区二区| 久久精品国内一区二区三区| 欧美成人精精品一区二区频| 久久激情综合网| 欧美风情在线| 国产精品永久| 亚洲激情视频网| 亚洲专区免费| 欧美1级日本1级| 一区二区三区久久网| 久久精品国产一区二区电影| 欧美电影专区| 国产伪娘ts一区| 99re这里只有精品6| 羞羞视频在线观看欧美| 欧美福利小视频| 亚洲欧美日韩专区| 欧美激情无毛| 激情文学综合丁香| 午夜精品久久久久久99热软件| 欧美大片91| 午夜久久久久久久久久一区二区| 欧美大片在线观看| 国产一区二区三区高清在线观看| 国产精品色在线| 亚洲精品日韩综合观看成人91| 欧美影院久久久| 99亚洲一区二区| 免费成人性网站| 在线播放中文字幕一区| 午夜精品美女久久久久av福利| 亚洲高清在线观看| 久久精品亚洲精品| 国产精品综合不卡av| 亚洲少妇诱惑|