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

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

?? ch4main.cpp

?? c編譯器詞法分析程序源碼
?? CPP
字號:
/**************************************************
 * Essential C++ -- Stanley Lippman
 * Addison-Wesley 
 * ISBN 0-201-48518-4
 * homepage: www.objectwrite.com
 * email: slippman@objectwrite.com
 *************************************************/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

class Stack {
public:    
	bool   push( const string& );
    bool   pop ( string &elem );
	bool   peek( string &elem );

    bool   find(  const string &elem ) const;
	int    count( const string &elem ) const;

	bool   empty() const { return _stack.empty(); }
	bool   full()  const { return _stack.size() == _stack.max_size(); }
	int    size()  const { return _stack.size(); }

private:
	vector<string> _stack;
};

bool
Stack::pop( string &elem ) 
{
    if ( empty() )
         return false;

    elem = _stack.back();
    _stack.pop_back(); 
    
    return true;
}

bool
Stack::peek( string &elem ) 
{
    if ( empty() )
         return false;

    elem = _stack.back();
    return true;
}

bool
Stack::push( const string &elem ) 
{
    if ( full() )
         return false;

    _stack.push_back( elem );
    return true;
}

#include <algorithm>

bool
Stack::find( const string &elem ) const
{
	vector<string>::const_iterator end_it = _stack.end();
	return std::find( _stack.begin(), end_it, elem ) != end_it;
}

int
Stack::count( const string &elem ) const 
{
	return std::count( _stack.begin(), _stack.end(), elem );
}

// Exercise 4.3

#include <string>
#include <map>
#include <iostream>
using namespace std;

class globalWrapper {
public:
    static int tests_passed()     { return _tests_passed; }
    static int tests_run()        { return _tests_run; }
    static int version_number()   { return _version_number; }
    static string version_stamp() { return _version_stamp; }
    static string program_name()  { return _program_name; }

    static void tests_passed( int nval )  { _tests_passed = nval; }
    static void tests_run( int nval )     { _tests_run = nval; }
    static void version_number( int nval ){ _version_number = nval; }

    static void version_stamp( const string& nstamp )
		{ _version_stamp = nstamp; }

    static void program_name( const string& npn )   
		{ _program_name = npn; }

private:
	static string _program_name;
    static string _version_stamp;
    static int    _version_number;
    static int    _tests_run;
    static int    _tests_passed;
};

string globalWrapper::_program_name;
string globalWrapper::_version_stamp;
int globalWrapper::_version_number;
int globalWrapper::_tests_run;
int globalWrapper::_tests_passed;

// =======================================================
// Exercise 4.4
// =======================================================
class UserProfile {
public:    
	enum uLevel { Beginner, Intermediate, Advanced, Guru };

    UserProfile( string login, uLevel = Beginner );
    UserProfile();

    // default memberwise initialization and copy sufficient
    // no explicit copy constructor or copy assignment operator
    // no destructor necessary ...

    bool operator==( const UserProfile& );
    bool operator!=( const UserProfile &rhs );

    // read access functions 
    string login() const { return _login; }
    string user_name() const { return _user_name; }
    int login_count() const { return _times_logged; }
    int guess_count() const { return _guesses; }
    int guess_correct() const { return _correct_guesses; }
    double guess_average() const;
    string level() const;

    // write access functions
    void reset_login( const string &val ){ _login = val; }
    void user_name( const string &val ){ _user_name = val; }

    void reset_level( const string& );
    void reset_level( uLevel newlevel ) { _user_level = newlevel; }

	void reset_login_count( int val ){ _times_logged = val; }
    void reset_guess_count( int val ){ _guesses = val; }
    void reset_guess_correct( int val ){ _correct_guesses = val; }

    void bump_login_count( int cnt=1 ){ _times_logged += cnt; }
    void bump_guess_count( int cnt=1 ){ _guesses += cnt; }
    void bump_guess_correct(int cnt=1){ _correct_guesses += cnt;}

 private:
   
    static string guest_login();

    string _login;
    string _user_name;
    int    _times_logged;
    int    _guesses;
    int    _correct_guesses;  
    uLevel _user_level;

    static map<string,uLevel> _level_map;
    static void init_level_map();
};

inline double UserProfile::guess_average() const
{ 

	return _guesses 
		   ? double( _correct_guesses ) / double( _guesses ) * 100
		   : 0.0; 
}

inline UserProfile::UserProfile( string login, uLevel level )
    : _login( login ), _user_level( level ),
      _times_logged( 1 ), _guesses( 0 ), _correct_guesses( 0 )
{}

#include <cstdlib>
inline UserProfile::UserProfile()
    : _login( "guest" ), _user_level( Beginner ), 
      _times_logged( 1 ), _guesses( 0 ), _correct_guesses( 0 )
{ 
   static int id = 0;
   char buffer[ 16 ];
   
   // Standard C library function in <cstdlib>
   // turns an integer into an ascii representation
   // _itoa( int value, char *buffer, int radix )
   _itoa( id++, buffer, 10 );

   // add a unique id during session to guest login
   _login += buffer;
}
   
/*
 * the hardest part of implementing this operator is trying
 * to understand what it means: _login & _user_name must be same
 * idea is that this would allow multiple UserProfiles,
 * if present, to be merged ... */
inline bool UserProfile::
operator==( const UserProfile &rhs )
{ 
     if ( _login == rhs._login && 
          _user_name == rhs._user_name ) 
          return true; 
	 else return false;
}

// note: this should appear after the definition
//       of the inline equality operator ...
inline bool UserProfile::
operator !=( const UserProfile &rhs )
       { return ! ( *this == rhs ); } 
    
inline string UserProfile::level() const
{
    static string _level_table[] = {
       "Beginner", "Intermediate", "Advanced", "Guru" };
    return _level_table[ _user_level ];
}

ostream& operator<<( ostream &os, const UserProfile &rhs )
{ /* output of the form:
   * stanl Beginner 12 100 10 10%
   **/
   os << rhs.login() << ' '
      << rhs.level() << ' '
      << rhs.login_count() << ' '
      << rhs.guess_count() << ' '
      << rhs.guess_correct() << ' '
      << rhs.guess_average() << endl;
   return os;
}

// this is probably overkill ...
// but it provides an excuse for a demonstration ...
map<string,UserProfile::uLevel> UserProfile::_level_map;

void UserProfile::init_level_map() 
{
    _level_map[ "Beginner" ] = Beginner;
    _level_map[ "Intermediate" ] = Intermediate;
    _level_map[ "Advanced" ] = Advanced;
    _level_map[ "Guru" ] = Guru;
}

inline void UserProfile::reset_level( const string &level )
{
    if ( _level_map.empty() ) 
		 init_level_map();

    map<string,uLevel>::iterator it;
    _user_level = (( it = _level_map.find( level )) 
                       != _level_map.end() )
                ? it->second : Beginner;
}        

istream& operator>>( istream &is, UserProfile &rhs )
{ // yes, this assumes the input is valid ...
    string login, level;
    is >> login >> level;
    
    int lcount, gcount, gcorrect;
    is >> lcount >> gcount >> gcorrect;

    rhs.reset_login( login );
    rhs.reset_level( level );

    rhs.reset_login_count( lcount );
    rhs.reset_guess_count( gcount );
    rhs.reset_guess_correct( gcorrect );

    return is;
}

void ex_4_4()
{
	UserProfile anon;
	cout << anon;

	UserProfile anon_too;
	cout << anon_too;

	UserProfile anna( "AnnaL", UserProfile::Guru );
	cout << anna;

	anna.bump_guess_count( 27 );
	anna.bump_guess_correct( 25 );
	anna.bump_login_count();

	cout << anna;

	cout << "OK: enter user profile data by hand to see if we can read it\n";
	cin >> anon;
	cout << anon;


}

typedef float elemType; 
class Matrix 
{
    friend Matrix operator+( const Matrix&, const Matrix& );
    friend Matrix operator*( const Matrix&, const Matrix& );

public:
    Matrix( elemType=0.,elemType=0.,elemType=0.,elemType=0.,
            elemType=0.,elemType=0.,elemType=0.,elemType=0.,
            elemType=0.,elemType=0.,elemType=0.,elemType=0.,
            elemType=0.,elemType=0.,elemType=0.,elemType=0. );
    Matrix( const elemType* );
    void operator+=( const Matrix& );
    elemType& operator()( int row, int column ) 
        { return _matrix[ row ][ column ]; }

    // makes transition to general matrix simpler
    int rows() const { return 4; }
    int cols() const { return 4; }

    elemType operator()( int row, int column ) const
        { return _matrix[ row ][ column ]; }

    ostream& print( ostream& ) const;

private:
    elemType _matrix[4][4];
};

inline ostream& operator<<( ostream& os, const Matrix &m )
       { return m.print( os ); }

Matrix operator+( const Matrix &m1, const Matrix &m2 ){
    Matrix result( m1 );
    result += m2;
    return result;
}

Matrix operator*( const Matrix &m1, const Matrix &m2 )
{
    Matrix result;
    for ( int ix = 0; ix < m1.rows(); ix++ ) {
	   for ( int jx = 0; jx < m1.cols(); jx++ ) {
	         result( ix, jx ) = 0;
	         for ( int kx = 0; kx < m1.cols(); kx++ )
		        result( ix, jx ) += m1( ix, kx ) * m2( kx, jx );
	   }
    }
    return result;
}

void Matrix::operator+=( const Matrix &m )
{
    for ( int ix = 0; ix < 4; ++ix )
        for ( int jx = 0; jx < 4; ++jx )
            _matrix[ix][jx] += m._matrix[ix][jx];
}

ostream& Matrix::print( ostream &os ) const 
{
    int cnt = 0;
    for ( int ix = 0; ix < 4; ++ix )
        for ( int jx = 0; jx < 4; ++jx, ++cnt )
        {
            if ( cnt &&  !( cnt % 8 )) os << endl; 
            os << _matrix[ix][jx] << ' ';
        }

	os << endl;
    return os;
}

Matrix::    
Matrix( elemType a11, elemType a12, elemType a13, elemType a14,
        elemType a21, elemType a22, elemType a23, elemType a24,
        elemType a31, elemType a32, elemType a33, elemType a34,
        elemType a41, elemType a42, elemType a43, elemType a44 )
{
   _matrix[0][0] = a11; _matrix[0][1] = a12;
   _matrix[0][2] = a13; _matrix[0][3] = a14;
   _matrix[1][0] = a21; _matrix[1][1] = a22;
   _matrix[1][2] = a23; _matrix[1][3] = a24;
   _matrix[2][0] = a31; _matrix[2][1] = a32;
   _matrix[2][2] = a33; _matrix[2][3] = a34;
   _matrix[3][0] = a41; _matrix[3][1] = a42;
   _matrix[3][2] = a43; _matrix[3][3] = a44;
}

Matrix::    
Matrix( const elemType *array )
{
    int array_index = 0;
    for ( int ix = 0; ix < 4; ++ix )
          for ( int jx = 0; jx < 4; ++jx )
                _matrix[ix][jx] = array[array_index++];
    
}

void ex_4_1() 
{

 	Stack st;
    string str;

	cout << "Please enter a series of strings.\n";
    while ( cin >> str && ! st.full() )
            st.push( str );

    if ( st.empty() ) {
         cout << '\n' << "Oops: no strings were read -- bailing out\n ";
         return;
	 }
         
    st.peek( str );
    if ( st.size() == 1 && str.empty() ) {
         cout << '\n' << "Oops: no strings were read -- bailing out\n ";
         return;
	 }

    cout << '\n' << "Read in " << st.size() << " strings!\n"
		   << "The strings, in reverse order: \n";

    while ( st.size() ) 
		 if ( st.pop( str ))
	         cout << str << ' ';
	
	cout << '\n' << "There are now " << st.size() 
		  << " elements in the stack!\n";
}

void ex_4_2() 
{
	Stack st;

	cout << "Please enter a series of strings.\n";

    string str;
    while ( cin >> str && ! st.full() )
            st.push( str );

    cout << '\n'
	     << "Read in " << st.size() << " strings!\n";

	cin.clear();

	cout << "what word to search for? ";
	cin >> str;
    
	bool found = st.find( str );
	int  count = found ? st.count( str ) : 0;

	cout << str << (found ? " is " : " isn\'t " )
		 << "in the stack. ";

	if ( found ) 
		 cout << "It occurs " << count << " times\n";
}

void ex_4_3()
{
	if ( globalWrapper::program_name().empty() )
	{
		 globalWrapper::program_name( "ex_4_3" );
		 globalWrapper::version_number( 1 );
		 globalWrapper::version_stamp( "A1-OK" );
	}

	if ( globalWrapper::program_name() == "ex_4_3" )
		 cout << "Wrapper seems to work ok\n";
	else cout << "Hmm. Wrapper doesn't seem to be correct\n";
}

void ex_4_5()
{
	Matrix m;
    cout << m << endl;

	elemType ar[16]={
		1., 0., 0., 0., 0., 1., 0., 0.,
		0., 0., 1., 0., 0., 0., 0., 1. };

	Matrix identity( ar );
	cout << identity << endl;

	// guarantee default memberwise copy works correctly
	Matrix m2( identity );
	m = identity;

	cout << m2 << endl; cout << m  << endl;

	elemType ar2[16]={
		1.3f, 0.4f, 2.6f, 8.2f, 6.2f, 1.7f, 1.3f, 8.3f,
		4.2f, 7.4f, 2.7f, 1.9f, 6.3f, 8.1f, 5.6f, 6.6f };

	Matrix m3( ar2 );
	cout << m3 << endl;

	Matrix m4 = m3 * identity;
	cout << m4 << endl;

	Matrix m5 = m3 + m4;
	cout << m5 << endl;

	m3 += m4;
	cout << m3 << endl;

}
	    
typedef void (*pf)();

pf tbl[]  = {
	&ex_4_1, &ex_4_2, &ex_4_3, &ex_4_4, &ex_4_5
};

int main() 
{
	// ex_4_1();
	// ex_4_2();
	// ex_4_3();
	// ex_4_4();
	// ex_4_5();

	// const int test_count = 5;
	// for ( int ix = 0; ix < test_count; ++ix )
	//       tbl[ ix ]();

	// tbl[0]();
	// tbl[1]();
	// tbl[2]();
	// tbl[3]();
	tbl[4]();

	return 0; // quiets vc++
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
337p亚洲精品色噜噜狠狠| 亚洲精品乱码久久久久久黑人| 欧美精品久久久久久久多人混战| 91亚洲精品久久久蜜桃| 99久久免费精品| 不卡的电影网站| 99国产精品久| 色综合咪咪久久| 欧日韩精品视频| 欧美日韩精品欧美日韩精品一综合| 欧美午夜理伦三级在线观看| 欧美伊人久久久久久久久影院| 欧美日免费三级在线| 欧美日韩精品欧美日韩精品| 7777女厕盗摄久久久| 日韩亚洲欧美高清| 精品美女一区二区| 欧美国产欧美综合| 亚洲特黄一级片| 亚洲高清视频中文字幕| 三级影片在线观看欧美日韩一区二区 | 美洲天堂一区二卡三卡四卡视频| 日韩二区三区四区| 久久国产精品色| 大胆欧美人体老妇| 91色|porny| 欧美群妇大交群的观看方式| 日韩欧美国产一区在线观看| 国产日韩欧美亚洲| 亚洲精品日产精品乱码不卡| 无吗不卡中文字幕| 国产精品99久久久久久似苏梦涵| 成人av在线资源网站| 色94色欧美sute亚洲线路一久| 欧美久久久久久久久久| www久久久久| 亚洲精品亚洲人成人网| 日韩精品国产精品| 国产成人鲁色资源国产91色综| 日本韩国一区二区| 精品日韩欧美在线| 最新日韩在线视频| 久久国产视频网| 色狠狠一区二区三区香蕉| 日韩午夜激情av| 中文字幕五月欧美| 欧美视频在线不卡| 精品国产一区二区三区av性色 | 亚洲免费观看视频| 日韩不卡在线观看日韩不卡视频| 国产精品一区一区三区| 欧美性猛交xxxx乱大交退制版| 精品久久人人做人人爰| 亚洲精品高清在线| 国内精品嫩模私拍在线| 日本韩国一区二区| 久久网这里都是精品| 亚洲福利视频一区二区| 国产成人亚洲精品狼色在线| 欧美精品tushy高清| 欧美韩国日本综合| 麻豆精品一区二区综合av| 91论坛在线播放| 国产色产综合产在线视频| 日韩精品欧美成人高清一区二区| 波多野结衣在线一区| 欧美videos大乳护士334| 樱桃视频在线观看一区| 国产成人免费在线视频| 91精品啪在线观看国产60岁| **性色生活片久久毛片| 国产盗摄精品一区二区三区在线| 欧美日韩一二区| 最新久久zyz资源站| 国产麻豆欧美日韩一区| 欧美一级一级性生活免费录像| 亚洲人成电影网站色mp4| 国产91精品在线观看| 欧美电视剧在线观看完整版| 亚洲午夜免费视频| 91一区二区在线观看| 欧美激情一区不卡| 国产呦精品一区二区三区网站| 在线播放91灌醉迷j高跟美女 | 国产精品青草综合久久久久99| 青娱乐精品视频在线| 欧美在线免费观看视频| 最新日韩av在线| 99亚偷拍自图区亚洲| 国产亚洲欧洲一区高清在线观看| 另类成人小视频在线| 正在播放亚洲一区| 天堂蜜桃91精品| 欧美日韩aaaaaa| 亚洲成人免费观看| 欧美在线|欧美| 亚洲国产精品久久人人爱| 一本一道久久a久久精品综合蜜臀| 日本一区二区三区久久久久久久久不 | 日韩精品一区二区三区视频在线观看| 午夜精品一区二区三区三上悠亚| 欧美三级乱人伦电影| 色综合久久久久综合体桃花网| 国产精品视频一二三区| 成人性生交大片免费看视频在线| 久久久久9999亚洲精品| 国产呦精品一区二区三区网站 | 五月天网站亚洲| 在线观看www91| 亚洲一卡二卡三卡四卡| 91老师片黄在线观看| 亚洲精品欧美激情| 欧美综合亚洲图片综合区| 亚洲一级不卡视频| 欧美精品一二三区| 久久电影网站中文字幕| 久久先锋影音av鲁色资源网| 国产伦精品一区二区三区免费迷| 久久精品人人爽人人爽| 国产盗摄视频一区二区三区| 国产精品久久久久久亚洲毛片| 粉嫩嫩av羞羞动漫久久久| 1024亚洲合集| 欧美日韩国产综合草草| 免费成人小视频| 欧美国产97人人爽人人喊| 91片在线免费观看| 爽爽淫人综合网网站| 欧美xxxxxxxx| 成人av免费在线观看| 亚洲一二三区在线观看| 日韩美女一区二区三区四区| 国产aⅴ综合色| 亚洲欧洲色图综合| 在线不卡中文字幕| 国产福利一区在线| 亚洲精品国产视频| 日韩一区二区三区av| 国产剧情一区二区| 亚洲精品欧美在线| 日韩免费视频线观看| 不卡视频在线观看| 天堂蜜桃一区二区三区| 国产嫩草影院久久久久| 在线观看亚洲a| 久久疯狂做爰流白浆xx| 成人欧美一区二区三区黑人麻豆 | 精品国产不卡一区二区三区| 成人免费高清在线| 婷婷成人综合网| 欧美经典一区二区三区| 欧美天堂亚洲电影院在线播放| 久久www免费人成看片高清| 中文字幕成人在线观看| 欧美精品tushy高清| 国产精品一级黄| 午夜欧美大尺度福利影院在线看| 久久久久久久久久久电影| 欧美色爱综合网| 懂色一区二区三区免费观看| 亚洲无线码一区二区三区| 久久久久久久综合日本| 欧美三级午夜理伦三级中视频| 国产精品一区二区不卡| 亚洲1区2区3区视频| 国产成人精品亚洲午夜麻豆| 亚洲一级二级三级| 国产精品进线69影院| 日韩一区二区视频在线观看| 99re这里只有精品首页| 久久国产视频网| 亚洲午夜电影在线观看| 国产欧美精品一区| 日韩欧美成人一区| 在线精品国精品国产尤物884a| 国产a视频精品免费观看| 日韩国产欧美在线观看| 亚洲欧美激情一区二区| 中文字幕av在线一区二区三区| 欧美一区二区三区啪啪| 欧美性大战xxxxx久久久| 99精品国产91久久久久久 | 日韩午夜精品电影| 91福利视频久久久久| 成人动漫一区二区| 狠狠狠色丁香婷婷综合久久五月| 五月激情六月综合| 亚洲一本大道在线| 亚洲美女屁股眼交3| 国产精品久久久久久久久免费丝袜 | 亚洲6080在线| 一区二区三区四区激情 | 精品在线观看免费| 三级久久三级久久| 亚洲国产aⅴ成人精品无吗| 一区二区免费在线播放| 亚洲免费伊人电影| 一区二区三区欧美日韩| 亚洲三级免费电影| 亚洲视频 欧洲视频|