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

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 閱讀(506) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美1区3d| 亚洲国产日日夜夜| 免费欧美日韩| 美女在线一区二区| 欧美成人精品h版在线观看| 久久精品一区二区三区中文字幕 | 亚洲国产91| 久久天堂精品| 欧美国产亚洲另类动漫| 欧美先锋影音| 亚洲综合999| 久久精品人人做人人爽电影蜜月| 久久免费视频一区| 亚洲三级毛片| 亚洲欧美日韩国产另类专区| 欧美一区二区视频在线观看| 久久久久久久久久看片| 欧美日韩精品在线视频| 国产欧美一区二区三区另类精品| 在线观看国产精品淫| 一区二区三区视频在线观看| 久久精品在线观看| 亚洲黄色片网站| 午夜日韩电影| 欧美成人精精品一区二区频| 国产精品主播| 亚洲精品一区二区三区蜜桃久| 亚洲综合视频1区| 欧美成人免费一级人片100| 亚洲图片在区色| 欧美大色视频| 狠狠色丁香婷综合久久| 亚洲午夜视频在线| 欧美大片91| 欧美在线观看视频在线| 欧美特黄一级大片| 亚洲日本aⅴ片在线观看香蕉| 久久成人免费网| 亚洲最新色图| 欧美激情精品久久久久久蜜臀 | 欧美视频日韩| 亚洲大胆人体视频| 久久国产精品免费一区| 日韩午夜精品| 农夫在线精品视频免费观看| 国产精品yjizz| 国产精品99久久久久久有的能看| 免费日韩一区二区| 亚洲午夜久久久久久久久电影院 | 亚洲影视在线播放| 欧美www视频在线观看| 亚洲一区欧美| 国产精品qvod| 亚洲视频免费观看| 亚洲国产91精品在线观看| 久久人人97超碰精品888| 欧美精品亚洲一区二区在线播放| 国产一区二区三区在线观看网站| 亚洲字幕一区二区| 一本色道久久88亚洲综合88| 欧美电影免费观看网站| 国产精品一区亚洲| 欧美日韩视频免费播放| 国产精品国码视频| 一本色道精品久久一区二区三区 | 经典三级久久| 久久久国际精品| 午夜视频久久久| 国产日韩精品视频一区| 久久se精品一区二区| 亚洲男人的天堂在线| 国产精自产拍久久久久久| 午夜久久美女| 午夜视频在线观看一区二区| 狠狠色丁香久久婷婷综合_中| 免费高清在线一区| 欧美成人tv| 中文精品在线| 亚洲欧美精品在线观看| 激情婷婷久久| 亚洲国产欧美一区二区三区丁香婷| 久久久久**毛片大全| 亚洲国产精品黑人久久久| 亚洲国产精品久久久久婷婷老年| 欧美日韩日本国产亚洲在线| 欧美一区二区黄色| 另类成人小视频在线| 亚洲欧美韩国| 久久久7777| 亚洲在线成人| 麻豆免费精品视频| 亚洲一区激情| 久久这里只有| 亚洲欧美另类综合偷拍| 久久影音先锋| 午夜精品理论片| 免费美女久久99| 午夜一区二区三区在线观看| 久久网站免费| 午夜欧美大尺度福利影院在线看| 久久婷婷亚洲| 欧美一区二区精品| 欧美电影免费观看大全| 久久久www| 国产精品av免费在线观看| 免费不卡中文字幕视频| 国产精品激情电影| 亚洲高清不卡在线观看| 国产一区二区三区在线播放免费观看| 欧美成年视频| 国产午夜精品美女毛片视频| 亚洲免费av观看| 最新亚洲电影| 久久精品国产99国产精品澳门| 一本久久综合| 欧美刺激性大交免费视频| 久久久亚洲精品一区二区三区| 欧美视频三区在线播放| 亚洲国产日韩欧美| 久久久精品国产免大香伊 | 久久综合给合| 久久精品一区二区国产| 国产精品v亚洲精品v日韩精品| 亚洲国产精品久久久久秋霞蜜臀| 激情国产一区| 欧美亚洲免费高清在线观看| 亚洲网站在线看| 欧美精品一区二区三区四区| 欧美高清视频一区二区| 加勒比av一区二区| 久久精品一区二区| 久久婷婷激情| 经典三级久久| 久久夜色精品一区| 免费日韩一区二区| 亚洲国产日韩美| 免费成年人欧美视频| 欧美激情一区二区三区在线视频| 在线观看日韩一区| 久久蜜桃资源一区二区老牛| 久久综合久久综合久久| 国内成+人亚洲+欧美+综合在线| 性欧美18~19sex高清播放| 欧美综合国产| 国内自拍一区| 老司机免费视频久久| 欧美激情一区二区三区高清视频 | 欧美日韩一区二区三区视频| 99国产精品| 欧美一区二区三区久久精品茉莉花| 国产精品久久夜| 午夜精品免费在线| 久久免费国产| 亚洲免费福利视频| 欧美视频国产精品| 亚洲一区影院| 美女久久网站| 夜夜嗨av一区二区三区网页 | 欧美日韩无遮挡| 亚洲精品乱码久久久久久蜜桃麻豆| 日韩一级黄色大片| 国产精品久久久久77777| 午夜精品久久久久久久久久久久 | 亚洲一区二区伦理| 国产亚洲一二三区| 欧美成年人在线观看| 一区二区91| 久久综合成人精品亚洲另类欧美| 亚洲黄色高清| 国产精品一区一区三区| 久久影视精品| 亚洲免费视频网站| 欧美第一黄网免费网站| 亚洲欧美日韩国产成人| 亚洲第一网站| 国产欧美精品| 蜜臀av国产精品久久久久| 一本不卡影院| 免费不卡欧美自拍视频| 国产精品极品美女粉嫩高清在线| 欧美一区二区三区日韩| 亚洲日本一区二区| 久久精品亚洲精品| 亚洲精品一区二区在线观看| 国产乱码精品一区二区三| 欧美~级网站不卡| 校园春色综合网| 亚洲精品资源美女情侣酒店| 久久综合国产精品| 午夜精品在线视频| 国产精品99久久久久久久vr | 91久久久在线| 国产香蕉97碰碰久久人人| 欧美日韩视频一区二区三区| 久久久精品网| 久久国产精品亚洲77777| 在线视频你懂得一区二区三区| 欧美激情亚洲一区| 久久阴道视频| 久久国产日韩|