C/C ++ input/output
I. Cin> when a space or line break '\ n' is encountered, the input ends.
This operator reads data based on the type of the following variable.
Enter the end condition: Enter, Space, and Tab are displayed.
Processing of Terminator: discards the terminator (Enter, Space, Tab) that ends the input in the buffer)
#include
[Analysis] When a string is read for the first time, spaces are stopped. abcd is read into str1, spaces are discard
Brush water problem, brush water problemportal:http://noi.openjudge.cn/ch0103/A+b*c (A+B)(a+b)/C04 with remainder Division05 floating-point values for the calculation of fractionsIt's all about seeing the test instructions can read.#include #include#includeusing namespace std; int Main () { int A, b; CIN>>a>>b; coutb; return 0 ;}View Code#include #include#includeusing namespace std; int Main () {int a,b,c;
true.
S. Good () if the stream is in the valid state, this function returns true
S. Clear () reset all statuses in stream s to valid
S. Clear (FLAG) sets the status of a specified condition in the stream to valid.
S. setstate (flat) adds a specified condition to S. The flag type is STRM: iostate.
S. rdstate () returns the current condition of stream s. the return value type is strm: iostate.
Here is a comprehensive example:
# Include # Include # Include # Include Using namespace std;Istream ge
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
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
, Grandpa D said that is probably because the abstraction of C happens to meet both the requirements of programmers and is easy to implement. Of course, C was once a common UNIX language. But in any case, Grandpa D laid the foundation for the widespread spread of C on the excellent aesthetic consciousness of programming languages.
Finally, gossip. Grandpa D's hobby is the same as Karl Malone, an nba bull: driving a truck. However, Grandpa D prefers NASCAR
introduced as a new cryptocurrency, making it the first cryptocurrency to be based on an Internet meme; the viral phenomenon, along with usage of the Comic Sans MS typeface, gave it "The Internet density of a large star" according to medium writer Quinn Norton.
In late December 2013, members of the U. s. congress produced material in the meme's style. huffington Post commented that doge was "killed" because of the congress members 'Usage of the meme.
By early 2014, Doge's popularity was sustain
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.