锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 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. 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. 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.
涓婇潰鏄祴璇曠爜
涓嬮潰鏄唬鐮?nbsp; 闃呰鍏ㄦ枃
]]>
]]>
]]>
]]>
{
typedef char Small;
class Big{char dummy[2];};
static Small Test(U) { }
static Big Test(...) { }
static T MakeT() { }
public:
enum { exists = sizeof(Test(MakeT())) == sizeof(Small)};
};
濡傛灉T鍙互杞崲涓篣 浜庢槸灝辮皟鐢═est(U)榪欎釜鍑芥暟 榪斿洖涓涓猚har錛?br>
濡傛灉涓嶈兘 灝辮皟鐢ㄤ嬌鐢?...)緙虹渷鍙傛暟鐨勫嚱鏁? 榪斿洖涓涓暟緇?br>
鐒跺悗瀵硅繑鍥炲艱繘琛屽垽鏂?...
]]>
]]>
sub readfpl
{
my @files;
my @chunks;
my $index = 0;
open(INPUT, "< $_[0]")
or die "can't open";
@chunks = split(m{file://}, <INPUT>);
foreach(@chunks)
{
if($_ =~ m/.+\.(mp3|wma|m4a)/)
{
$files[$index] = $&;
$index ++;
}
}
print $files[0];
return @files;
}
my @files = readfpl($ARGV[0]);
my $string;
foreach(@files){
$string = $_;
# the next while get name from path
while( substr($string, 1) =~ m{\\.+\.(mp3|wna|m4a)}) {
$string = $ARGV[0].$&;
}
rename $_, string;
}
灝囬欐浠g⒓瀛樼偤movefpl.pl鐒跺悗鍦ㄥ懡浠よ鎵撳叆 movefpl.pl 鎾斁鍒楄〃鐨勫叏璺緫 瑕佸瓨姝屾洸鐨勬柊璺緫
灝卞彲浠ヤ簡鍛?鍛靛懙
]]>
Background
Description

Figure 1 Output from a sample solution
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 );
}
]]>
]]>
1 2 3
,. abc def
4 5 6
ghi jkl mno
7 8 9
pqrs tuv wxyz
璀瑾幾鍏?43
閫插叆閫欏嬪搱甯岄噷闈㈠幓灝嬫壘
key[43] -> [if] -> [he] -> [id] -> [ie]-> [ge] -> [gf] -> 0
閭勫彲浠ヨ幾鍏ユ洿澶氱殑 鍛靛懙銆?br>
浠ユ欏炴帹錛屽鏋滄槸鎷奸煶杓稿叆涔熸槸涓妯o紝鍙笉閬庤澶氶茶涓嬈″搱甯屻傚緸鎷奸煶鍝堝笇鍒板叿楂旂殑婕㈠瓧閲岄潰鍘匯?br>
涓嶉亷鎷奸煶杓稿叆鐨勭媭鎱嬫鎳夎┎鏇村京闆滀竴浜涖傚洜鐐烘嫾闊寵幾鍏ュ彲浠ユ牴鎿氬墠涓鍊嬪瓧渚嗘帹鏂峰彲鑳藉嚭鐝劇殑涓嬩竴鍊嬪瓧銆?br>
鍏跺 涓嶅彧鏄墜姍燂紝鍙鏄嬌鐢ㄦ暩瀛楅嵉鐩ょ殑姍熷櫒閮藉彲浠ヤ嬌鐢ㄩ欐ǎ瀛愮殑杓稿叆娉曘?br>
浣跨敤閫欑ó綆楁硶鐨勮畩紼倓鍙互瀵︾従涓鍊嬪ソ鐜╃殑娓告埐錛氬氨鏄幾鍏ヤ竴鍊嬪柈瑭烇紝鐒跺悗杓稿嚭鎵鏈夎垏瀹冪祫鎴愬厓绱犵浉鍚岀殑鍠(灝辨槸杓稿叆stop 瀹冨彲浠ヨ幾鍑簍ops絳夊柈瑭?銆傚叿楂斾篃鏄嬌鐢ㄥ搱甯屻傚搱甯岀湡鏄竴鍊嬪ソ綆楁硶
]]>