Requirements:
Understanding C ++ stream operation functions
Understanding the two methods of I/O Stream format Control
Basic output stream (cout) Operations1. Use the stream insertion operator (# Include Void main (){Char C [] = "good morning ";Cout }Running result:Good morningPress any key to continue2. Use member functions// Ostream put (char );// Output one character for continuous use# Include Void main (){Cout. Put ('A'). Put ('\ n ');}Running result:APress any key to continue// Ostream
The simplest Recursion Method: (this algorithm times out .)
// The time complexity is 2 ^ n# Include # Include # Include # Include # Include Using namespace STD;Const int max = 1001;Typedef struct{Int value;Int volume;} Bone;Bone B [Max];Int make (int I, Int J) // the I-th item, current remaining capacity J{If (I Return 0;Int R1 = 0, R2 = 0;If (j> = B [I]. Volume) // The value of the I-th item that can be placed in the backpack{R1 = make (I-1, J-B [I]. Volume) + B [I]. value;}R2 = make (I-1, J);
";
Char cname[200];
sstrsstr>>cname;
cout System ("pause");
}
Next, we will learn about the status of the input/output of the relevant knowledge, C + + responsible for the input/output system includes the results of each input/output operation of the record information. These current state information is contained in an object of type Io_state. Io_state is an enumeration type (just like Open_mode), and here is the value it contains.
Goodbit No errorsEofbit has reached the end of the fil
# Include # Include # Include # Include # Include
Using namespace std;
Typedef struct{Int num; // student IDChar name [20]; // Student nameChar textID [9]; // student admission ticket No.} Student;Vector Int a3; // use a3 to store the number of test roomsInt a4; // used to store the number of people in the last unfilled classroomConst CODE = 18; // The school CODE has been set to 18;Vector
Void input_students_info () // function for inputting Student Information{String str;While (! (Str = "N"
The speed of java mentioned here is limited to java syntax, including input and output, Operation Processing, string and high-precision processing, conversion between systems, etc. It can solve some high-precision questions on OJ.1. input:The format is: interval cin = new second (new BufferedInputStream (System. in ));Routine:Import java. io .*;Import java. math .*;Import java. util .*;Import java. text .*;Public class Main{Public static void main (St
:
# Include
Using std: map; // using namespace std;
1) map constructor map provides a total of six constructor functions, which involve the memory distributor. I will skip this article. Below we will be exposed to some map constructor methods, we usually construct a map using the following method:
map
mapStudent;
2) data insertion
After constructing the map container, We can insert data into it. Here are three data insertion methods:
A) insert pair data using the insert function
1 opening and closing of files1.1 Defining a Stream objectIfsteam iflie;//file input Stream objectIfsteam iflie;//file output stream objectFsteam iflie;//file input/output stream object1.2 Open Filevoid Open (const unsigned char* filename,int mode,int accessfilebuf:opnprot)Mode is the open way, the relevant tag as shown in (iOS) Attention:(1) usually open way with | combine togetherIos::in|ios::out//Read-write mode open fileIos::out|ios::binary//binary write mode open file(2) Iftream: Default
1. introduce several common functions first
1) getline (istream is, string s) stores the characters read from the input stream is \ n, or the end of the file or reading errors. It is equivalent to reading a line of characters into s.
2) getline (istream is, string s, char c) stores the characters read from the input stream is always ended with c, or the end of the file or the reading error) in string s.
For example, getline (cin, str ,'#')
3) getchar
:
// Name: example2_1.cpp
// Alias: Rubish
# Include
# Include
Int compare (const void * arg1, const void * arg2 );
Void main (void)
{
Const int max_size = 10; // The maximum number of elements allowed in the array
Int num [max_size]; // integer Array
// Read an integer from the standard input device and accumulate the input quantity,
// Until the input is non-integer data
Int n;
For (n = 0; cin> num [n]; n ++ );
// Quic
C ++ note 13: input, output, and file operations and notes in c ++Friday, April February 6, 2015
Soon to Friday, I feel that I have been reviewing this week. After these two weeks, I think the basic knowledge of c ++ should be almost mastered. I can pursue something higher.
Today I will talk about the input, output, and file operations in c ++. The basic syntax of c ++ is almost over. It is possible that basic grammar knowledge will not be emphasized in future notes.
-------------- Split line --
iostream Library of C + + standard library learning notes (i) Introduction and Istream,ostream classes of iostream libraries and Cin,cout objects
The standard input Output library of C language is stdio.h is a function library rather than a class library.This includes our most commonly used scanf printf, which are independent global functions because the C language does not support classes.C + + standard input Output library iostream is a class librar
capturing decimalsConstant folding: #define和const, const defines a constant, you cannot try to change it by changing the value of the variable, but you can change it by referencing its address, that is, by the pointer. Constant folding says that in the compile phase, the variable is replaced with a value, while the constant is recorded in the symbol table, and define is not the same, in three cases, the const allocates memory.Example: #include int main (){using namespace Std;const int I=20;int
Huadian North Wind BlowsKey laboratory of cognitive computing and application, Tianjin UniversityDate: 2015/8/27Because the code is not debugged, the paper draft renders completely correctlyPOJ need to use the state compression dynamic planning, link http://poj.org/problem?id=3254Online to see a lot of people write code, referring to a top-down with a memo dynamic programming solution, wrote a bottom-up dynamic programming solutionBottom up:#include #include #include #include using namespace STD
debug than C + +. There is one more option in a specific contest.(7) Learning Java is good for future work. There are many places in the world where Java people are more likely to be than C + +.(8) Java can make you look more like a hoof animal (ox).0x02Here are some of the problems that ACM-ICPC players have encountered with Java programming at first:1. Basic input and output:(1) The New scanner class for JDK 1.5.0 provides a good basis for input and is simply for ACM-ICPC.The general usage is
, you must specify a pointer or reference to the object.8.2 Item StatusCondition statusBadbit marks a system-level failure, cannot be recovered, Failbit is an IO error, usually can be fixed, eofbit is set when a file terminator is encountered, and the Failbit is set at the same time.If either bad, fail, or EOF is true, the stream is in an error state, and if none of the three are true, the good operation returns True.The clear operation resets the condition to a valid state.The SetState operatio
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.