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

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>
            国产精品高潮视频| 亚洲激情校园春色| 伊人久久久大香线蕉综合直播 | 久久综合国产精品| 久久国产高清| 老司机aⅴ在线精品导航| 欧美暴力喷水在线| 欧美三级小说| 国内外成人在线视频| 亚洲国产va精品久久久不卡综合| 亚洲国产精品毛片| 一本色道久久综合亚洲精品不| 亚洲欧美国产制服动漫| 性视频1819p久久| 美日韩精品免费| 日韩写真视频在线观看| 午夜精品视频在线观看| 牛人盗摄一区二区三区视频| 欧美日韩一区在线| 国产一区二区黄色| 99国产精品久久| 久久精品亚洲一区二区| 亚洲国产二区| 欧美亚洲日本网站| 欧美人与性动交α欧美精品济南到| 国产精品午夜av在线| 亚洲黄色成人| 久久福利精品| 99re国产精品| 美女精品在线| 国内成+人亚洲| 午夜精品理论片| 亚洲激情av| 久久免费视频网| 国产日韩欧美在线播放| 亚洲精品一区二区网址| 久久久亚洲精品一区二区三区 | 欧美刺激午夜性久久久久久久| 久久亚洲精品网站| 国产精品欧美一区喷水| 亚洲精品视频中文字幕| 久久久久中文| 亚洲综合色噜噜狠狠| 欧美剧在线免费观看网站| 一区免费在线| 久久蜜臀精品av| 亚洲欧美日韩国产综合精品二区| 欧美激情网友自拍| 亚洲国产日韩欧美在线图片| 久久婷婷国产综合精品青草| 亚洲一区免费看| 欧美午夜理伦三级在线观看| 一二三区精品福利视频| 亚洲国产成人在线播放| 欧美.日韩.国产.一区.二区| ●精品国产综合乱码久久久久| 久久精品国产2020观看福利| 亚洲主播在线| 国产三级精品三级| 欧美在线视频一区二区| 亚洲欧美日韩一区二区三区在线观看 | 久久综合影视| 国内精品美女在线观看| 久久久久久久国产| 久久九九国产| 亚洲国产精品精华液2区45| 免费一级欧美片在线观看| 美国十次成人| 99xxxx成人网| 亚洲香蕉在线观看| 国产一区二区看久久| 嫩草成人www欧美| 欧美高清在线精品一区| 一区二区三区欧美| 一区二区三区蜜桃网| 国产精品资源| 另类欧美日韩国产在线| 欧美精品日韩精品| 午夜欧美大尺度福利影院在线看| 欧美一级在线播放| 亚洲精品国产系列| 亚洲午夜一区二区三区| 黄色国产精品| 日韩亚洲成人av在线| 国产精品一区二区久久| 另类酷文…触手系列精品集v1小说| 免费日韩视频| 先锋影音一区二区三区| 久久伊人一区二区| 亚洲免费在线电影| 久久中文在线| 亚洲自拍偷拍一区| 久久亚洲精品视频| 国产精品超碰97尤物18| 好吊一区二区三区| 亚洲精品男同| 国产麻豆视频精品| 亚洲高清av在线| 国产女人水真多18毛片18精品视频| 免费成人高清| 国产精品丝袜91| 亚洲激情在线视频| 国产一区二区三区自拍| 日韩图片一区| 亚洲高清在线| 欧美在线free| 午夜精品久久一牛影视| 欧美精品999| 女女同性精品视频| 国产日韩欧美麻豆| 亚洲免费成人av| 亚洲二区在线视频| 欧美在线一二三四区| 亚洲一区日本| 欧美日本免费一区二区三区| 免费91麻豆精品国产自产在线观看| 国产精品video| 亚洲国产欧美另类丝袜| 加勒比av一区二区| 午夜视频在线观看一区| 亚洲制服少妇| 欧美日韩免费观看一区=区三区 | 久久亚洲国产成人| 国产精品无码专区在线观看| 99精品视频免费观看| 亚洲精品在线免费观看视频| 久久婷婷综合激情| 久久综合福利| 国产一区二区av| 久久不射中文字幕| 久久蜜桃香蕉精品一区二区三区| 国产精品视频自拍| 亚洲社区在线观看| 亚洲一区二区三区午夜| 欧美色图五月天| 一区二区高清视频| 亚洲一区二区精品| 国产精品美女久久久久久2018| 在线视频一区观看| 欧美影院视频| 精品动漫3d一区二区三区免费版 | 99精品视频网| 亚洲在线中文字幕| 国产伦精品一区二区三区四区免费| 亚洲图色在线| 久久成人精品| 黄网站免费久久| 欧美成人久久| 亚洲精品一区二区三区四区高清| 一本色道久久综合亚洲精品按摩| 欧美日韩国产探花| 在线视频精品一区| 欧美在线网站| 精品51国产黑色丝袜高跟鞋| 麻豆av一区二区三区久久| 91久久国产自产拍夜夜嗨| 91久久久亚洲精品| 在线亚洲欧美专区二区| 欧美视频在线观看一区二区| 亚洲一级在线| 久久综合给合久久狠狠色| 亚洲级视频在线观看免费1级| 欧美精品一区二| 亚洲综合视频在线| 欧美护士18xxxxhd| 亚洲一区精品在线| 影音先锋中文字幕一区二区| 欧美激情中文不卡| 香蕉久久夜色精品| 最新日韩中文字幕| 久久国产主播| 一本色道久久综合狠狠躁篇怎么玩| 国产精品一区二区久久久| 老牛影视一区二区三区| 亚洲色诱最新| 欧美激情自拍| 久久国产精品99精品国产| 亚洲美女啪啪| 精品成人一区二区三区| 欧美性色aⅴ视频一区日韩精品| 欧美专区中文字幕| 999在线观看精品免费不卡网站| 久久精品国产999大香线蕉| 亚洲精品美女在线观看| 国产一区二区三区av电影| 欧美日韩亚洲不卡| 久久亚洲私人国产精品va媚药 | 久久免费国产| 中国亚洲黄色| 亚洲国产婷婷香蕉久久久久久99 | 亚洲全黄一级网站| 久久免费观看视频| 欧美一区二区三区久久精品茉莉花| 亚洲国产成人在线| 黄色成人av| 国产片一区二区| 国产精品久久午夜| 欧美日韩一区二区在线播放| 欧美1区2区视频| 久久久伊人欧美|