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

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>
            久久综合九色综合久99| 国产精品视频一二| 亚洲裸体在线观看| 国产精品午夜av在线| 欧美日韩国产限制| 欧美高清日韩| 欧美日韩情趣电影| 欧美久久久久久蜜桃| 欧美日韩高清在线观看| 欧美亚一区二区| 欧美午夜一区二区| 国产精品视频免费观看www| 国产人久久人人人人爽| 很黄很黄激情成人| 亚洲国产1区| 亚洲激情国产精品| 一区二区三区国产在线观看| 亚洲欧美综合v| 欧美成人精品一区二区| 亚洲成在线观看| 免费看的黄色欧美网站| 免费不卡亚洲欧美| 亚洲精品资源美女情侣酒店| 一本色道久久综合亚洲精品不| 这里只有精品视频| 欧美亚洲色图校园春色| 久久久久一区二区| 欧美成在线观看| 国产精品久久久久久久久借妻| 国产在线精品自拍| 一区二区三区四区五区精品| 欧美在线观看一区二区| 亚洲国产日韩欧美在线动漫| 亚洲一区日韩在线| 久久久一区二区| 国产精品成人一区二区网站软件 | 欧美成人在线免费视频| 欧美日本高清一区| 国产在线播精品第三| 亚洲另类春色国产| 欧美在线免费视屏| 亚洲人成人一区二区在线观看| 亚洲午夜国产成人av电影男同| 老**午夜毛片一区二区三区| 国产精品综合av一区二区国产馆| 亚洲免费观看高清完整版在线观看熊 | 乱人伦精品视频在线观看| 国产精品久久久久久久电影 | 亚洲精品系列| 久久夜色精品国产| 亚洲一区二区三区影院| 蜜桃伊人久久| 在线观看日韩精品| 久久精品日韩欧美| 亚洲视频精品| 欧美体内she精视频| 日韩视频一区二区三区在线播放免费观看 | 久久久久久香蕉网| 在线亚洲高清视频| 欧美精品激情| 精品成人在线视频| 久久久精品一区| 亚洲欧美在线网| 国产精品福利片| 亚洲尤物精选| 日韩亚洲欧美高清| 欧美激情中文不卡| 99国产精品| 亚洲精品在线视频| 欧美精品成人91久久久久久久| 亚洲国产精品一区二区第四页av | 国产精品久久久久999| 亚洲午夜在线视频| 亚洲无亚洲人成网站77777| 亚洲黄色免费网站| 欧美国产日本在线| 亚洲精品乱码久久久久久按摩观| 亚洲电影中文字幕| 欧美激情亚洲视频| 亚洲人成网站777色婷婷| 欧美成人一品| 欧美日本韩国一区| 亚洲中无吗在线| 亚洲欧美日韩天堂| 精品盗摄一区二区三区| 亚洲黄网站黄| 国产精品久久久久影院色老大 | 精品51国产黑色丝袜高跟鞋| 美女诱惑一区| 欧美激情aⅴ一区二区三区| 亚洲乱码国产乱码精品精98午夜| 亚洲破处大片| 国产精品久久77777| 欧美在线视频导航| 噜噜噜91成人网| 亚洲午夜激情免费视频| 性做久久久久久| 亚洲国产精品久久久久| 日韩网站免费观看| 黄色精品一区| 日韩写真在线| 一区二区在线视频| 亚洲毛片在线看| 韩国成人福利片在线播放| 欧美国产日韩一二三区| 国产精品激情| 亚洲国产另类久久精品| 欧美日韩国产一级| 欧美调教vk| 免费成人高清视频| 国产精品美女午夜av| 欧美成在线观看| 国产精品婷婷| 美女主播视频一区| 国产精品美女久久久浪潮软件 | 久久久一二三| 欧美体内谢she精2性欧美| 久久免费黄色| 欧美视频在线观看| 欧美黄色精品| 久久精品国产在热久久| 中日韩美女免费视频网站在线观看| 欧美伊久线香蕉线新在线| 一区二区免费在线播放| 久久久91精品国产一区二区精品| 亚洲视频免费观看| 欧美jizz19性欧美| 麻豆精品网站| 国产一区二区日韩精品| 一区二区av在线| 亚洲日韩第九十九页| 久久久久久尹人网香蕉| 欧美在线视频二区| 国产精品一区=区| 亚洲视频二区| 亚洲已满18点击进入久久| 欧美美女bb生活片| 最新精品在线| 亚洲久久成人| 欧美高潮视频| 亚洲国产精品尤物yw在线观看| 91久久精品国产91久久| 免费亚洲电影在线观看| 欧美大片国产精品| 亚洲日韩中文字幕在线播放| 欧美gay视频激情| 亚洲精品综合精品自拍| 亚洲一区中文字幕在线观看| 国产欧美精品日韩区二区麻豆天美| 亚洲一区二区三区四区在线观看 | 麻豆精品在线视频| 欧美国产日韩精品免费观看| 亚洲乱码国产乱码精品精 | 免费不卡中文字幕视频| 欧美黄免费看| 国产精品99久久不卡二区| 欧美日韩中文字幕在线| 亚洲自拍偷拍麻豆| 久久久久免费视频| 亚洲高清在线| 欧美四级电影网站| 欧美在线|欧美| 欧美国产综合视频| 久久一区欧美| 亚洲一二三级电影| 亚洲一区二区三区精品视频| 欧美日韩视频在线观看一区二区三区| 亚洲激情午夜| 亚洲永久在线观看| 国产一区久久| 亚洲精品美女在线观看| 亚洲日本理论电影| 国产精品男女猛烈高潮激情| 国产精品99久久久久久久女警| 国产视频一区在线观看一区免费| 久久偷看各类wc女厕嘘嘘偷窃| 欧美jjzz| 一本色道久久88综合日韩精品| 国产欧美日本| 欧美一区深夜视频| 蜜桃av综合| 亚洲最黄网站| 尤物精品国产第一福利三区 | aⅴ色国产欧美| 亚洲欧美三级伦理| 欧美特黄一区| 欧美激情 亚洲a∨综合| 亚洲午夜视频| 麻豆精品精华液| 欧美伊人久久久久久久久影院 | 久久久久久久国产| 夜夜爽99久久国产综合精品女不卡| 亚洲天堂av在线免费| 国产美女扒开尿口久久久| 亚洲图片欧洲图片日韩av| 亚洲国产精品国自产拍av秋霞 | 久久手机精品视频| 99v久久综合狠狠综合久久| 欧美高清在线观看| 午夜欧美大片免费观看|