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

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>
            国产精品你懂的在线| 一区二区三区视频在线| 一区二区高清在线| 9l国产精品久久久久麻豆| 99视频在线精品国自产拍免费观看 | 亚洲二区视频| 在线一区二区三区做爰视频网站| 99亚洲伊人久久精品影院红桃| 在线性视频日韩欧美| 午夜精品视频网站| 另类国产ts人妖高潮视频| 欧美激情在线免费观看| 国产精品久久久久三级| 影音先锋欧美精品| 日韩视频一区二区三区在线播放| 亚洲一区久久久| 欧美jizzhd精品欧美喷水 | 亚洲国产欧美一区| 日韩一级网站| 久久久水蜜桃| 国产精品多人| 亚洲国产欧美一区二区三区丁香婷| 99精品99久久久久久宅男| 久久国产精品免费一区| 亚洲精品欧美专区| 欧美一区二区在线免费播放| 欧美国产三级| 韩国欧美国产1区| 亚洲视屏在线播放| 久久午夜视频| 亚洲在线视频观看| 欧美女同视频| 在线不卡免费欧美| 午夜精品免费在线| 亚洲精品久久久久久久久久久久| 欧美一区二区三区在| 欧美日韩国产三区| 1024国产精品| 欧美在线视频一区二区| 亚洲精品1区2区| 久久影音先锋| 激情综合色综合久久综合| 亚洲欧洲99久久| 日韩一级黄色大片| 欧美日韩不卡合集视频| 亚洲精品日产精品乱码不卡| 久久视频在线视频| 亚洲欧美文学| 国产欧美一区二区视频| 亚洲图片欧美一区| 亚洲精品裸体| 欧美国产日本在线| 亚洲国产专区校园欧美| 免费观看在线综合色| 久久久久国产精品一区三寸| 国产一区二区三区丝袜| 久久国产精品久久久久久久久久 | 亚洲视频观看| 欧美午夜精品久久久久久久| 日韩午夜在线视频| 亚洲精品久久久一区二区三区| 免费在线亚洲欧美| 久久综合999| 亚洲成人在线免费| 欧美国产日韩一区| 欧美高清日韩| 亚洲专区一二三| 亚洲一区自拍| 国产欧美日韩亚洲精品| 久久av一区二区| 久久国产精品第一页| 在线精品视频免费观看| 欧美大片在线影院| 欧美日本高清一区| 亚洲欧美精品在线观看| 先锋亚洲精品| 一区二区在线观看视频在线观看| 麻豆九一精品爱看视频在线观看免费| 久久久精彩视频| 亚洲美女中文字幕| 亚洲综合欧美日韩| 激情久久久久久久久久久久久久久久| 麻豆精品视频在线观看视频| 欧美福利专区| 欧美一区二区三区免费视频| 欧美一区二区视频在线观看| 亚洲欧洲精品一区二区三区波多野1战4 | 午夜精品影院| 亚洲成人在线免费| 一区二区电影免费在线观看| 国产精品日韩一区| 欧美激情一区二区三级高清视频| 欧美日韩一级大片网址| 久久福利毛片| 欧美理论在线播放| 久久久久久久综合狠狠综合| 欧美96在线丨欧| 午夜在线a亚洲v天堂网2018| 久热综合在线亚洲精品| 一区二区高清视频| 久久精品免费| 亚洲欧美激情诱惑| 毛片一区二区| 久久精品国产91精品亚洲| 欧美电影在线播放| 久久亚洲欧美| 国产精品一区二区女厕厕| 亚洲国产成人av好男人在线观看| 国产精品久久久久久影院8一贰佰| 欧美高清日韩| 国产自产高清不卡| 亚洲一区二三| 一区二区不卡在线视频 午夜欧美不卡'| 午夜国产一区| 亚洲免费在线视频| 欧美精品久久久久久久免费观看| 久久综合久久综合这里只有精品| 国产精品日韩高清| 野花国产精品入口| 亚洲免费观看高清完整版在线观看熊 | 亚洲视频在线视频| 亚洲免费av片| 欧美激情1区2区3区| 欧美大片免费观看| 在线日韩欧美视频| 久久成人精品无人区| 欧美一区二区三区四区在线观看| 欧美久久久久久| 亚洲电影免费观看高清完整版在线观看 | 红杏aⅴ成人免费视频| 亚洲线精品一区二区三区八戒| 亚洲免费av电影| 欧美激情精品久久久久久久变态| 欧美大尺度在线观看| 激情亚洲成人| 狼人天天伊人久久| 欧美大片91| 最近看过的日韩成人| 母乳一区在线观看| 亚洲国产精品久久久久秋霞蜜臀| 永久久久久久| 裸体歌舞表演一区二区| 欧美ab在线视频| 亚洲区中文字幕| 欧美日韩国产小视频| 中文国产成人精品久久一| 亚洲免费在线播放| 国产婷婷色一区二区三区四区| 午夜欧美精品久久久久久久| 久久久久网站| 亚洲国产精品一区二区www| 欧美v亚洲v综合ⅴ国产v| 亚洲精品网址在线观看| 在线中文字幕一区| 国产一区二区剧情av在线| 久久乐国产精品| 亚洲免费观看在线观看| 久久国产精品网站| 91久久精品www人人做人人爽| 欧美激情第一页xxx| 亚洲亚洲精品三区日韩精品在线视频| 午夜精品福利在线| 亚洲成色www8888| 欧美午夜精品久久久久久人妖| 亚洲欧美日韩网| 欧美黄色精品| 亚洲欧美日韩直播| 亚洲国产日韩欧美在线99| 国产精品99一区二区| 久久久综合网| 亚洲欧美综合网| 亚洲成人在线免费| 亚洲最新色图| 久久亚洲影院| 中国成人黄色视屏| 狠狠色综合日日| 亚洲婷婷综合久久一本伊一区| 欧美专区在线观看一区| 亚洲精品乱码久久久久久蜜桃麻豆 | 欧美日韩国产页| 久久狠狠亚洲综合| 99热在这里有精品免费| 久久躁日日躁aaaaxxxx| 亚洲性视频网址| 亚洲欧洲日韩综合二区| 国产美女一区二区| 欧美精品乱人伦久久久久久 | 91久久国产精品91久久性色| 国产精品大全| 欧美日韩国产成人在线| 久久综合九色综合欧美就去吻| 亚洲视频在线一区| 亚洲欧洲偷拍精品| 欧美高清视频一二三区| 久久久免费精品| 欧美在线1区| 亚洲欧美欧美一区二区三区| 999亚洲国产精| 亚洲日本va午夜在线影院| 黄色另类av|