Http://www.cnblogs.com/keam37/ keam all reprinted please indicate the source
This article describes the usage of functions contained in the
# Inclde
Cin, cout, and cerr are the most basic input and output streams. They are operated by the operators "
For example, read two strings from the keyboard and then merge them into the output
string s1,s2;cin>>s1>>s2;cout
Run the following input:
Hello
Keambar
implement in other languages.
C + + input cout and output cininput and output are not formal components of the C + + language. Neither C nor C + + itself provides a specialized statement structure for input and output. The input output is not defined by C + + itself, but is defined in the I/O library provided by the compilation system.
The output and input of C + + is implemented in the form of "stream".
Information about the definition of CIN,
cout is an output stream object in C + + , which is defined in the header file iostream header file. (The stream object can be regarded as the information flow inside the computer, can carry the message inside the computer flow ), usage:cout" The namespace STD is the space used to hold identifiers used by C + +, which must be introduced when an identifier for that space is needed, or the program is not recognized. You can also take it directly from the namespace std:: identifier. Although the
When using C + + 's getline function, two problems are encountered, summarized as follows:1. Sometimes we will find Getline (CIN,STR) When we write the program, such statements are not executed, but are skipped directly,The general solution is to getline a sentence before adding cin.ignore () or a sentence cin.get (), or repeating geilineExplain:Check carefully, before you write Getline () function, must have entered the ENTER key, whether you enter a
Initialization{Int I;For (I = 0; I {HT [I]. Key = nullkey;HT [I]. Next = NULL;}}Int hash_insert (hashtable HT, employee * em){Int key = hash (EM-> key_code );Employee * P;If (HT [Key]. Key = nullkey){HT [Key]. Key = key;HT [Key]. Next = em;}Else if (HT [Key]. Key = Key) // if a conflict occurs, use the link address to resolve the conflict.{P = HT [Key]. Next;While (p-> next! = NULL) // find the insert position and insert it to the end of the table Synonym{P = p-> next;}P-> next = em;}Return 1;}
Tips for C ++ Primer Chapter 8, primerchapterChapter 1 IO library types and header files
Header file: Class
Iostream (read/write stream): istream ostream iostream
Fstream (read/write file): ifstream ofstream fstream
Sstream (read/write memory string object): istringstream ostringstream stringstream
PS:
Ifstream and istringstream inherit from istream;
Ofstream and ostringstream inherit from ostream;
Generally, a derived class object can be used as its base class object. For example, you can use
as the endl tag.
B. the stream is out of scope, so it is revoked.
C. Corresponding input stream request input (that is, cout will refresh the output when using cin input ).
D. The stream buffer is full.
E. explicitly tell the stream to refresh the output buffer. Is the flush () method.
Cout
Cout. flush ();
Not all output streams are buffered. For example, the cerr Stream does not buffer its output.
Handle output errors: output errors may b
This article from http://developer.51cto.com/art/201107/277395.htm
Use Getline () to read input rows
When the program uses CIN input, CIN uses a blank character and a line terminator to separate the values. Use the Getline member function to read a whole line of text and separate different fields based on the value to be entered.
getline(char*line,intsize,char='"n')
The second parameter is the maximu
1. Usage of CINChar ch;Cin. Get (CH); // only one character is accepted (input 12, CH is only assigned to 1)Cout 2. Differences between the CH, ++ CH and CH + 1 variables
Cout Cout 3. Clever Writing of if condition sentenceWhen writing an if (I = 0) Statement, the Code may encounter a logic error that is hard to be verified due to missing "=.If (0 = I) is written. When a "=" is missing, an error is reported during code compilation, so it is easy to fi
Php jpgraph library is very powerful and can generate images in the background
Background generation is useful when you need to export chart-type reports. Of course, you must use class libraries such as highcharts, echarts, and anycharts for front-end visualization.
What is troublesome is the Chinese Garbled text. There are three garbled characters:
Legend
SetStickLabels
Title
First, describe my environment and version:
Ubuntu12.04
PHP 5.3.10-1
Jpgraph 3.5.0b1
File fileencoding = UTF
Who has the implementation code of the QeePHP Quick Start function? I 'd like to refer to the user registration example below. thank you, I have used it. please refer to the white list of stocks for reference, isn't there a quick start chm file? just repeat it ., Http://www.google.com.hk/search? Client = aff-cs-360chromium amp; ie = UTF-8 amp; could you tell me who has QeePHP Quick Start function implementation code, I would like to refer to the use
1. the nature of the input and outputThe input and output in C + + is carried out through the stream, and the output input is done by convection, typically directing a stream (redirect), emptying the stream, and adding new elements to the stream. C + + considers the input output as a byte stream, extracts bytes from the stream as input, and inserts bytes into the byte stream when output.2. using CIN and its methods for input The
# Include # Include # Include # Include # Include # Include # Include # Include # Define random (x) (RAND () % x)Using namespace STD;
Void output (int sf) // open the TXT record question{If (Sf = 1){Ofstream OUTFILE ("formula.txt", IOS: Out );If (! OUTFILE){Cout Exit (1 );}OUTFILE OUTFILE. Close ();}}
Int istrue_input (INT num01) // determines whether the input 0, 1 complies with the standard.{While (1){If (num01! = 0 num01! = 1){Cout Cin> num01;}Els
Java in ACM/ICPC, javainacmicpc
Directory
Features of Java in ACM/ICPC
Notes for using Java in ACM/ICPC
Java and high-precision computing
1. Features of Java in ACM/ICPC
The syntax of Java is almost the same as that of C ++.
Java is not much slower than C/C ++ in executing computation intensive tasks, but it is only slow in I/O operations.
Java is simple and powerful, and some things are more convenient to implement using Java
For example: input and output, string parsing, and high precision
Are the simplest to remember.This is my git address: HTTPS://GITHUB.COM/YANJINYUN/CLANGUAGETCPUDPThe simplest server for TCP:intMainintargcConst Char*argv[]) { intLISTENFD, ACCEPTFD; structsockaddr_in sin, cin; Socklen_t Clen; Charbuf[1024x768]; Signal (SIGCHLD, sig_ign); LISTENFD= Socket (pf_inet, Sock_stream,0); Sin.sin_family=pf_inet; Sin.sin_port= Htons (Atoi (argv[2])); Sin.sin_addr.s_addr= Inet_addr (argv[1]); Bind (LISTENFD, (structSOC
"Please enter a string of integers and any number of spaces:"; One A - while(Cin >>i) - { theSum + =i; - while(Cin.peek () = =' ' ) - { -Cin.Get(); + } - if(Cin.peek () = ='\ n' ) + { A Break; at } - } - -cout "? á1?ê?:"Endl; - - return 0; in}View CodeC + + version analysisThis program uses the Stream object
101
Two-Point distanceTime Limit: 3000 MS | memory limit: 65535 KBDifficulty: 1DescriptionEnter two coordinates (x1, Y1), (X2, Y2) (0 InputEnter an integer N (0 Each group occupies one row and consists of four real numbers, representing X1, Y1, X2, and Y2 respectively. Data is separated by spaces.OutputFor each group of input data, a row is output, and the result is retained with two decimal places.Sample Input20 0 0 10 1 1 0 sample output1.001.41
# Include # Include Main (){Int N;Float a, B,
101
Two-Point distanceTime Limit: 3000 MS | memory limit: 65535 KBDifficulty: 1DescriptionEnter two coordinates (x1, Y1), (X2, Y2) (0 InputEnter an integer N (0 Each group occupies one row and consists of four real numbers, representing X1, Y1, X2, and Y2 respectively. Data is separated by spaces.OutputFor each group of input data, a row is output, and the result is retained with two decimal places.Sample Input20 0 0 10 1 1 0 sample output1.001.41
# Include # Include Main (){Int N;Float a, B,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.