亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main5.c

?? c++ primer 源代碼
?? C
字號:
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <map>

#include <iostream.h>
#include <fstream.h>

#include <stddef.h>
#include <ctype.h>

typedef pair<short,short>           location;
typedef vector<location,allocator>  loc;
typedef vector<string,allocator>    text;
typedef pair<text*,loc*>            text_loc;

extern vector<string,allocator> *retrieve_text();
extern text_loc *separate_words( const vector<string,allocator>* );
extern void display_text_locations( text_loc* );
extern void filter_text( vector<string,allocator>*, string filter );
extern void strip_caps(  vector<string,allocator>* );
extern void suffix_text( vector<string,allocator>* );
extern void suffix_s( string& );
extern void display_map_text( map<string,loc*,less<string>,allocator>*);
extern map< string, loc*, less<string>, allocator >*
       build_word_map( const text_loc *text_locations );

int main() 
{
	vector<string,allocator>   *text_file      = retrieve_text();
        text_loc 		   *text_locations = separate_words( text_file );

        string filt_elems( "\",.;:!?)(" );
        filter_text( text_locations->first, filt_elems );
        suffix_text( text_locations->first );	
	strip_caps(  text_locations->first );

	map<string,loc*,less<string>,allocator> *text_map = build_word_map( text_locations );

	ostream_iterator< string > output( cout, "\n" );

	cout << "----------- about to generate text read --------------\n";
        copy( text_file->begin(), text_file->end(), output );

	cout << "-------- about to generate word and location data ----\n";
	display_map_text( text_map );

	return 0;
}

vector<string,allocator>*
retrieve_text()
{
	string file_name;
	
	cout << "please enter file name: ";
	cin  >> file_name;

	ifstream infile( file_name.c_str(), ios::in );
	if ( !infile ) {
		cerr << "oops! unable to open file "
		     << file_name << " -- bailing out!\n";
		exit( -1 );
	}
	else cout << "\n";

	vector<string,allocator> *lines_of_text = new vector<string,allocator>;
        string textline;

        typedef pair<string::size_type, int> stats;
        stats maxline;
	int   linenum = 0;

        while ( getline( infile, textline, '\n' ))
	{
		cout << "line read: " << textline << "\n";

		if ( maxline.first < textline.length() )
		{
		     maxline.first = textline.length();
		     maxline.second = linenum;
		}

		lines_of_text->push_back( textline );
		linenum++;
	}

	cout << "\n";
        cout << "number of lines: " 
             << lines_of_text->size() << "\n";

	cout << "maximum length: "  
	     << maxline.first << "\n";

        cout << "longest line: "    
	     << (*lines_of_text)[ maxline.second ] << "\n";
	
	return lines_of_text;
}

text_loc*
separate_words( const vector<string,allocator> *text_file )
{
        // ok: now have all the lines. wish to grab the
        // individual words: look for blanks:

        vector<string,allocator>   *words     = new vector<string,allocator>;
	vector<location,allocator> *locations = new vector<location,allocator>;

        for ( short line_pos = 0; line_pos < text_file->size(); line_pos++ )
        {
		short  word_pos = 0;
                string textline = (*text_file)[ line_pos ];

                cout << "textline: " << textline << endl;

                string::size_type eol = textline.length();
                string::size_type pos = 0, prev_pos = 0;

                while (( pos = textline.find_first_of( ' ', pos )) != string::npos )
                {
                        cout << "eol: "  << eol << " "
			     << "pos: "  << pos << " "
			     << "line: " << line_pos << " "
			     << "word: " << word_pos << " "
                             << "substring: " 
                             << textline.substr( prev_pos, pos-prev_pos ) 
			     << "\n";

                        words->push_back( textline.substr( prev_pos, pos - prev_pos ));
			locations->push_back( make_pair( line_pos, word_pos ));

                        word_pos++; pos++; prev_pos = pos;
                }

	        cout << "last word on line substring: " 
                     << textline.substr( prev_pos, pos-prev_pos ) 
		     << "\n";

                words->push_back( textline.substr( prev_pos, pos - prev_pos ));
		locations->push_back( make_pair( line_pos, word_pos ));
        }
	
        return new text_loc( words, locations );
}

void 
display_text_locations( text_loc *text_locations )
{
        vector<string,allocator>   *text_words     = text_locations->first;
        vector<location,allocator> *text_locs      = text_locations->second;

        register int elem_cnt = text_words->size();

        if ( elem_cnt != text_locs->size() )
        {
	     cerr << "oops! internal error: word and position vectors "
		  << "are of unequal size\n"
		  << "words: " << elem_cnt << " "
		  << "locs: "  << text_locs->size() 
		  << " -- bailing out!\n";
	     exit( -2 );
	}

        for ( int ix = 0; ix < elem_cnt; ix++ ) 
        {
		cout << "word: " << (*text_words)[ ix ] << "\t"
		     << "location: (" 
		     << (*text_locs)[ix].first  << ","
		     << (*text_locs)[ix].second << ")"
		     << "\n";
	}

        cout << endl;
}

void 
filter_text( vector<string,allocator> *words, string filter )
{
	vector<string,allocator>::iterator iter = words->begin();
	vector<string,allocator>::iterator iter_end = words->end();

        if ( ! filter.size() )
             filter.insert( 0, "\".," );

        cout << "filter elements: " << filter << endl;

	while ( iter != iter_end )
	{
		cout << "filter_text: " << *iter << endl; 

                string::size_type pos = 0;
                while (( pos = (*iter).find_first_of( filter, pos )) != string::npos )
                {
                        cout << "found! : pos: " 
			     << pos << "\t" 
			     << (*iter)[pos] << endl;

			// this is wrong: erases from pos to npos
                        // (*iter).erase(pos);
                        (*iter).erase(pos,1);

			cout << "after: " << *iter << endl;
                }

		cout << "finished with word: " << *iter << endl;

		iter++;
	}
}

void
suffix_text( vector<string,allocator> *words )
{
        vector<string,allocator>::iterator iter = words->begin();
        vector<string,allocator>::iterator iter_end = words->end();

        while ( iter != iter_end )
        {
                cout << "suffix_text: " << *iter << endl;

		// if 3 or less characters, let it be
		if ( (*iter).size() <= 3 ) {
		     iter++; 
		     continue;
                }

		if ( (*iter)[ (*iter).size()-1 ] == 's' )
		     suffix_s( *iter );

		// additional suffix handling goes here ...

                iter++;
        }
}

void
suffix_s( string &word )
{
	cout << "suffix_s -- word passed in: " << word << endl;

	string::size_type spos = 0;
	string::size_type pos3 = word.size()-3;

        // "ous", "ss", "is"
	string suffixes( "oussis" );

        if ( ! word.compare( pos3, 3, suffixes, spos, 3 ) ||
             ! word.compare( pos3+1, 2, suffixes, spos+2, 2 ) ||
             ! word.compare( pos3+1, 2, suffixes, spos+4, 2 ))
        {
		cout << "suffix_s: found immutable suffix: "
		     << word << endl;
		return;
	}

	string ies( "ies" );
        if ( ! word.compare( pos3, 3, ies ))
	{
	     word.replace( pos3, 3, 1, 'y' );
	     cout << "suffix_s -- word returned: " << word << endl;

	     return; 
	}

	// erase ending 's'
	word.erase( pos3+2 );
	cout << "suffix_s -- word returned: " << word << endl;
}

void
strip_caps( vector<string,allocator> *words )
{
        vector<string,allocator>::iterator iter = words->begin();
        vector<string,allocator>::iterator iter_end = words->end();

	string caps( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );

        while ( iter != iter_end )
        {
                cout << "strip_caps: " << *iter << endl;

                string::size_type pos = 0;
                while (( pos = (*iter).find_first_of( caps, pos )) != string::npos )
                {
                        cout << "found! : pos: "
                             << pos << "\t"
                             << (*iter)[pos] << endl;

                        (*iter)[ pos ] = tolower( (*iter)[pos] );

                        cout << "after: " << *iter << endl;
                }

                cout << "finished with word: " << *iter << endl;

                iter++;
        }
}

map< string, loc*, less<string>, allocator >*
     build_word_map( const text_loc *text_locations )
{
     map< string, loc*, less<string>, allocator > *word_map = new map< string, loc*, less<string>, allocator >;
     typedef map<string,loc*, less<string>, allocator>::value_type value_type;

     // iterate through the the words, entering the key/pair

     vector<string,allocator>   *text_words = text_locations->first;
     vector<location,allocator> *text_locs  = text_locations->second;

     register int elem_cnt = text_words->size();
     for ( int ix = 0; ix < elem_cnt; ++ix )
         {
                cout << "word: " << (*text_words)[ ix ] << "\t"
                     << "location: ("
                     << (*text_locs)[ix].first  << ","
                     << (*text_locs)[ix].second << ")"
                     << "\n";

                if ( ! word_map->count((*text_words)[ix] ))
                {  // not present, add it:
                   cout << "adding word: " << (*text_words)[ix] << endl;
                   loc *ploc = new vector<location,allocator>;
                   ploc->push_back( (*text_locs)[ix] );
                   word_map->insert( value_type( (*text_words)[ix], ploc ));
                }
                else (*word_map)[(*text_words)[ix]]->push_back( (*text_locs)[ix] );

                // enter word -- check if new or already entered.
                // if new, provide key/value -- allocate new instance
                // if already has entry, just add new value
         }

        cout << endl;
	return word_map;
}

void 
display_map_text( map<string,loc*,less<string>,allocator> *text_map )
{
	typedef map<string,loc*,less<string>,allocator> map_text;
	map_text::iterator iter = text_map->begin(), iter_end = text_map->end();
	
	while ( iter != iter_end ) {
		cerr << "word: " << (*iter).first << " ";

		int           loc_cnt = 0;
		loc          *text_locs = (*iter).second;
		loc::iterator liter     = text_locs->begin(), 
		  	      liter_end = text_locs->end();

		while ( liter != liter_end ) 
		{
			if ( loc_cnt ) 
			     cerr << ","; 
			else ++loc_cnt;
 
			// cerr << "(" << (*liter).first 
			//      << "," << (*liter).second << ")";
			cerr << "(" << (*liter).first 
			     << "," << (*liter).second << ")";

			++liter;
		}
		
		cerr << ")\n";
		++iter;
	}

        cerr << endl;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品综合网| 热久久国产精品| 久久国产日韩欧美精品| 成人免费高清视频在线观看| 5566中文字幕一区二区电影| 国产精品久久久一本精品| 久久99国产精品免费网站| 在线免费不卡视频| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲第一福利一区| 92国产精品观看| 日本一区二区三区在线观看| 久久国产日韩欧美精品| 欧美一区二区在线不卡| 亚洲成人久久影院| 欧洲精品一区二区三区在线观看| 欧美国产精品专区| 国产一区二区三区免费看| 欧美一级片在线观看| 午夜精品久久一牛影视| 色婷婷综合视频在线观看| 亚洲国产精品成人综合| 国产成人免费视频精品含羞草妖精| 884aa四虎影成人精品一区| 亚洲成人动漫av| 欧美精品少妇一区二区三区| 亚洲一区二区综合| 欧美日韩综合色| 午夜视频在线观看一区| 欧美三级电影在线看| 香蕉乱码成人久久天堂爱免费| 在线观看国产精品网站| 亚洲乱码中文字幕综合| 91精品1区2区| 亚洲国产美女搞黄色| 欧美日韩不卡一区| 日本va欧美va瓶| 精品久久国产97色综合| 国精产品一区一区三区mba视频 | 亚洲乱码国产乱码精品精小说| 99在线精品一区二区三区| 亚洲视频中文字幕| 欧美日韩精品一区二区天天拍小说| 午夜视频在线观看一区二区三区| 91精品国产一区二区三区蜜臀| 麻豆精品一区二区| 日本一区二区三区电影| 色呦呦国产精品| 蜜臀精品一区二区三区在线观看| 精品日本一线二线三线不卡| 国产成人在线视频网址| 亚洲黄色小说网站| 欧美一区二区二区| aa级大片欧美| 日韩激情一区二区| 国产精品拍天天在线| 色婷婷精品大在线视频| 美女网站一区二区| 国产精品家庭影院| 制服丝袜亚洲播放| 国产91富婆露脸刺激对白| 亚洲精品日韩专区silk| 日韩欧美www| 波多野结衣一区二区三区| 亚洲风情在线资源站| 国产亚洲精品资源在线26u| 在线国产亚洲欧美| 国产精品91一区二区| 亚洲一区二区在线视频| 久久久.com| 日韩一区二区麻豆国产| 91在线丨porny丨国产| 久久精品国产99国产| 最新成人av在线| 日韩免费在线观看| 在线观看国产一区二区| 国产成人精品一区二| 日韩高清不卡在线| 日韩毛片在线免费观看| 久久嫩草精品久久久精品| 欧美日韩精品一区二区三区| 成人性色生活片免费看爆迷你毛片| 视频一区中文字幕| 一区二区三区蜜桃网| 中文字幕不卡三区| 欧美精品一区二区三区蜜桃| 欧美三电影在线| 91美女精品福利| 高清shemale亚洲人妖| 日产精品久久久久久久性色| 伊人夜夜躁av伊人久久| 亚洲欧洲韩国日本视频| 久久精品在这里| 亚洲精品一区二区三区福利| 欧美日韩一卡二卡三卡| 色综合天天综合网天天看片| 国产sm精品调教视频网站| 精品一二三四区| 捆绑变态av一区二区三区 | 亚洲天堂av一区| 久久精品亚洲一区二区三区浴池| 欧美福利一区二区| 欧美日韩一区二区三区高清| 91在线免费看| 一本到三区不卡视频| 99久久婷婷国产精品综合| 国产成人精品免费在线| 国产精品综合在线视频| 国产乱子轮精品视频| 激情综合色播五月| 韩国欧美一区二区| 国产高清成人在线| 国产91在线|亚洲| av在线播放一区二区三区| jvid福利写真一区二区三区| 不卡视频在线看| 一本色道**综合亚洲精品蜜桃冫| 91精品1区2区| 91麻豆精品国产91久久久久久久久| 在线观看日韩电影| 欧美久久一二区| 欧美一区二区福利在线| 久久一区二区三区四区| 国产精品嫩草久久久久| 亚洲欧美日韩电影| 亚洲不卡一区二区三区| 日韩精品成人一区二区在线| 国内外精品视频| 99天天综合性| 欧美日韩欧美一区二区| 欧美va在线播放| 欧美高清在线一区| 一区二区三区免费观看| 麻豆91在线观看| 成人高清视频免费观看| 在线观看日韩精品| 日韩亚洲欧美高清| 欧美激情一区二区三区在线| 亚洲激情一二三区| 蜜臀国产一区二区三区在线播放| 激情五月激情综合网| 91伊人久久大香线蕉| 制服丝袜av成人在线看| 国产亚洲精品资源在线26u| 一区二区三区日韩欧美精品 | 懂色一区二区三区免费观看| 在线视频中文字幕一区二区| 欧美一区二区三区在| 国产精品国产三级国产| 青青国产91久久久久久| 成人av在线影院| 91精品国产色综合久久| 国产精品毛片大码女人| 丝袜美腿成人在线| 成人精品小蝌蚪| 精品日韩一区二区| 亚洲黄色片在线观看| 国产精品自拍一区| 欧美精品在欧美一区二区少妇| 国产日韩成人精品| 日本aⅴ精品一区二区三区 | 亚洲黄一区二区三区| 国产综合久久久久影院| 欧美日韩国产一级二级| 中文字幕乱码一区二区免费| 日韩成人一区二区| 在线精品视频一区二区三四| 国产精品视频麻豆| 麻豆久久久久久久| 欧美人狂配大交3d怪物一区| 国产精品久久三| 国产黄人亚洲片| 日韩精品一区二区三区中文不卡| 一区二区不卡在线播放| 成人动漫中文字幕| 26uuu另类欧美| 蜜臀精品一区二区三区在线观看| 在线中文字幕一区| 中文字幕中文字幕一区二区| 国产精品资源站在线| 精品嫩草影院久久| 免播放器亚洲一区| 欧美日韩国产系列| 午夜精品久久一牛影视| 在线免费观看成人短视频| 亚洲另类在线视频| 99视频超级精品| 国产精品天美传媒| 国产不卡视频一区二区三区| 精品国精品国产尤物美女| 美脚の诱脚舐め脚责91| 欧美一级二级在线观看| 美女看a上一区| 精品国产伦一区二区三区观看方式| 日本欧美在线观看| 日韩一区二区在线播放| 免费看精品久久片| 精品99999| 风间由美一区二区三区在线观看| 国产欧美一区二区在线|