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

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一区二区| 久久人人爽人人爽爽久久| 亚洲剧情一区二区| 一区二区高清视频| 国产欧美日本| 亚洲国产美女| 欧美日韩不卡一区| 欧美一区二区三区日韩| 久久久久欧美精品| 一区二区三区日韩精品视频| 亚洲尤物影院| 激情综合五月天| 日韩视频精品| 樱桃成人精品视频在线播放| 亚洲精品美女久久7777777| 国产精品一区二区三区成人| 欧美黑人在线播放| 国产精品亚洲精品| 亚洲国产精品久久久久婷婷884 | 亚洲欧美在线另类| 亚洲国产成人porn| 亚洲与欧洲av电影| 亚洲巨乳在线| 久久精品视频免费播放| 亚洲一区二区精品| 久久综合五月| 久久aⅴ国产欧美74aaa| 欧美激情亚洲自拍| 免费成人av| 国产欧美日韩91| 亚洲免费观看高清在线观看 | 亚洲高清自拍| 欧美影院在线播放| 亚洲欧美在线aaa| 欧美久久视频| 亚洲黄色免费网站| 狠狠综合久久av一区二区小说| 一区二区不卡在线视频 午夜欧美不卡'| 在线欧美福利| 久久理论片午夜琪琪电影网| 欧美一区二区三区四区在线观看| 欧美日韩精品久久久| 欧美电影专区| 在线观看亚洲| 久久精品91久久久久久再现| 欧美一区二区日韩一区二区| 国产精品盗摄久久久| 日韩亚洲精品在线| 99国产欧美久久久精品| 欧美mv日韩mv国产网站| 欧美岛国激情| 91久久精品日日躁夜夜躁欧美| 久久亚洲精品伦理| 欧美成人精品在线观看| 在线看片第一页欧美| 久久视频在线看| 蜜桃久久精品乱码一区二区| 影音先锋日韩有码| 久久亚洲免费| 亚洲成色精品| 欧美一级精品大片| 欧美亚洲视频| 国产亚洲美州欧州综合国| 欧美一级二区| 久久综合激情| 亚洲三级国产| 欧美日韩一区二区三区在线看 | 亚洲国产裸拍裸体视频在线观看乱了中文 | 欧美日韩一级大片网址| 99精品国产一区二区青青牛奶| 亚洲调教视频在线观看| 国产精品久久久久一区二区三区共| 亚洲午夜久久久久久尤物| 翔田千里一区二区| 精品动漫一区| 欧美日韩国产系列| 亚洲综合二区| 毛片一区二区三区| 中国亚洲黄色| 国产日韩精品综合网站| 久久另类ts人妖一区二区| 亚洲精品美女| 欧美一区二视频| 亚洲欧洲一区二区在线播放| 欧美日韩一区精品| 欧美一区免费视频| 亚洲国产第一页| 午夜欧美理论片| 1769国内精品视频在线播放| 欧美精品一区视频| 欧美一区激情| 99国产精品视频免费观看一公开| 欧美一区高清| 一本久道久久综合婷婷鲸鱼| 国产一区二区三区在线观看网站| 欧美国产精品中文字幕| 欧美亚洲网站| 亚洲精选视频免费看| 久久精品网址| 亚洲小说春色综合另类电影| 韩国精品在线观看| 国产精品户外野外| 免费亚洲一区| 久久国产福利国产秒拍| 一区二区三区日韩在线观看| 欧美 日韩 国产精品免费观看| 性久久久久久久久| 一区二区高清在线| 亚洲国产日韩欧美综合久久 | 欧美连裤袜在线视频| 久久久久久久91| 欧美在线不卡| 亚洲欧美成人精品| 99re6热在线精品视频播放速度| 快播亚洲色图| 久久久久久久久一区二区| 亚洲午夜黄色| 一区二区三区高清视频在线观看| 亚洲电影自拍| 亚洲高清一二三区| 在线国产精品播放| 狠狠综合久久| 一区二区三区亚洲| 好看的日韩av电影| 国产一区美女| 韩日欧美一区二区三区| 国产欧美在线看| 国产日韩欧美电影在线观看| 国产精品久久91| 国产精品视频精品视频| 欧美四级在线观看| 欧美午夜精品久久久久久浪潮| 欧美精品在线观看91| 欧美精品一区二区三区久久久竹菊 | 久久这里有精品15一区二区三区| 欧美影片第一页| 久久精品亚洲国产奇米99| 久久丁香综合五月国产三级网站| 欧美一区二区性| 久久久久久久久久码影片| 久久伊人免费视频| 欧美成人激情视频免费观看| 欧美国产欧美亚州国产日韩mv天天看完整 | 亚洲国产日韩欧美在线图片| 亚洲韩国精品一区| 99热免费精品在线观看| 在线亚洲免费| 欧美一区观看| 欧美成人亚洲| 亚洲欧洲在线看| 中文精品在线| 久久精品电影| 欧美成人一区二区在线| 欧美三区免费完整视频在线观看| 国产精品成人观看视频国产奇米| 国产精品一区一区三区| 精品动漫3d一区二区三区免费| 亚洲国产清纯| 午夜久久99| 欧美承认网站| 中国av一区| 久久久久久久久久久久久9999| 免费亚洲婷婷| 国产精品日韩精品欧美精品| 在线观看日韩av电影| 亚洲视频大全| 蜜桃av噜噜一区| 一区二区成人精品| 久久亚洲精品网站| 国产精品jvid在线观看蜜臀 | 欧美日韩在线观看视频| 国产一区二区三区电影在线观看 | 欧美色网在线| 在线视频国产日韩| 亚洲一区二区三区精品在线观看 | 一本大道久久a久久综合婷婷| 久久大综合网| 国产精品激情电影| 在线免费观看视频一区| 亚洲欧美日本日韩| 亚洲国产成人午夜在线一区| 香蕉久久一区二区不卡无毒影院 | 激情综合在线| 先锋影音网一区二区| 最新精品在线| 久久精品在这里| 国产精品一区二区女厕厕| 99视频在线观看一区三区| 乱人伦精品视频在线观看| 亚洲一区国产精品| 欧美日韩国产色综合一二三四| 亚洲二区在线观看| 久久综合色婷婷| 午夜视频在线观看一区二区|