voidget_URL(const string &host, const string &path){ // Your code here.
// You will need to connect to the "http" service on // the computer whose name is in the "host" string, // then request the URL path given in the "path" string. TCPSocket sock1; sock1.connect(Address(host, "80"));
// Then you'll need to print out everything the server sends back, // (not just one call to read() -- everything) until you reach //谢谢你的原注释这里把eof用双引号括起来哈,我还以为是字符串"eof"呢,结果不是 // the "eof" (end of file). //看仓库文档的示例之后,我以为需要创建两个socket,一个读一个写,结果是我理解错了 //不过从原理来看也应该是一个socket才对 //auto recvd = sock2.read(); //cout << recvd << endl;
classByteStream { private: // Your code here -- add private members as necessary. std::deque<char> _queue; size_t _capacity_size; size_t _written_size; size_t _read_size; bool _end_input; bool _error{}; //!< Flag indicating that the stream suffered an error. public: ByteStream(constsize_t capacity);
//! \name "Input" interface for the writer //接口函数还没有试验过 classInputInterface { private: ByteStream* _input_stream; public: InputInterface(ByteStream* stream) : _input_stream(stream) {} size_twrite(const std::string &data){ return _input_stream->write(data); } }; //! Write a string of bytes into the stream. Write as many //! as will fit, and return how many were written. //! \returns the number of bytes accepted into the stream size_twrite(const std::string &data);
//! \returns the number of additional bytes that the stream has space for size_tremaining_capacity()const;
//! Signal that the byte stream has reached its ending voidend_input();
//! Indicate that the stream suffered an error. voidset_error(){ _error = true; } //!@}
//! \name "Output" interface for the reader //接口函数还没有试验过 classOutputInterface { private: ByteStream* _output_stream; public: OutputInterface(ByteStream* stream) : _output_stream(stream){} std::string peek_output(constsize_t len){ return _output_stream->peek_output(len); } voidpop_output(constsize_t len){ _output_stream->pop_output(len); } }; //! Peek at next "len" bytes of the stream //! \returns a string std::string peek_output(constsize_t len)const;
//! Remove bytes from the buffer voidpop_output(constsize_t len);
//! Read (i.e., copy and then pop) the next "len" bytes of the stream //! \returns a string std::string read(constsize_t len);
//! \returns `true` if the stream input has ended boolinput_ended()const;
//! \returns `true` if the stream has suffered an error boolerror()const{ return _error; }
//! \returns the maximum amount that can currently be read from the stream size_tbuffer_size()const;
//! \returns `true` if the buffer is empty boolbuffer_empty()const;
//! \returns `true` if the output has reached the ending booleof()const; //!@}
//! \name General accounting //!@{
//! Total number of bytes written size_tbytes_written()const;
//! Total number of bytes popped size_tbytes_read()const; //!@} };
//! \param[in] len bytes will be copied from the output side of the buffer string ByteStream::peek_output(constsize_t len)const{ size_t pop_size = min(len, _queue.size()); returnstring(_queue.begin(), _queue.begin() + pop_size); }
//! \param[in] len bytes will be removed from the output side of the buffer voidByteStream::pop_output(constsize_t len){ size_t pop_size = min(len, _queue.size()); _read_size += pop_size; for(size_t i = 0; i < pop_size; i++){ _queue.pop_front(); } }
//! Read (i.e., copy and then pop) the next "len" bytes of the stream //! \param[in] len bytes will be popped and returned //! \returns a string std::string ByteStream::read(constsize_t len){ string data = this->peek_output(len); this->pop_output(len); return data; }
Edit the html file that just saved, overwrite jQuery reference <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> as <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script> or other reference you trust.
class Solution { public: void rotate(vector<vector<int>>& matrix) { int n = matrix.size(); int tri = 0; for (int i = 0; i < n; i++) { for (int j = 0+tri; j < n; j++) { int tr=matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = tr; } tri++; } for (int i = 0; i < n; i++) { reverse(matrix[i].begin(),matrix[i].end()); } } };