Exercise 9.26: If you have the following IA definition, copy ia into a vector container and a list container. Use the erase function of a single iterator parameter version to set the odd value of the list containerelement is removed and then the even values in the vector container are removed.Code:Summary: (1) When you define vector variables, you can initialize them with arrays;(2) The vector container returns an iterator to the next element after the element is deleted using the erase function
;BreakCase ' O ':++ocnt;BreakCase ' U ':++ucnt;Break}}coutreturn 0;}Code Listing 2:#include using namespace Std;int main (){unsigned acnt=0,ecnt=0,icnt=0,ocnt=0,ucnt=0;Char ch;coutwhile (CIN>>CH){Switch (CH){Case ' a ':++acnt;Case ' E ':++ecnt;Case ' I ':++icnt;Case ' O ':++ocnt;Case ' U ':++ucnt;}}coutreturn 0;}We soon came to the conclusion that the first is obviously that the input character will increase the corresponding number of characters, then jump out of the loop; Code 2 because there
#include This article is from the "Running Donkey" blog, please make sure to keep this source http://amgodchan.blog.51cto.com/9521586/1567734C + + Primer (fifth edition) Exercise 6.33
placesDouble 64bit, valid bit is 10 decimal placesLong 64bit, the least significant bit is 10 decimal placesThere are two ways to represent floating-point literals: decimal and scientific notation.1. Double literal in decimal type1.e0 the literal value of the scientific notation of double type.The default floating-point number is the double type. If the setting you want to display is float, you need to add an F or F after the literal value.For example:3.14F, 2.f are floating-point literals of t
An error occurred in the sample program of the Chinese Version C Primer Plus Fifth edition, primerplus
The program with an error occurs on the ListItemCount () and Traverse () Functions on page 1 in Chapter 2.
The original book contains list. c defined by all functions as follows:
1 # include
However, the calling methods in film3.c are as follows:
1 Traverse (movies, showmovies); // pass the copy of the
-programreturn valueParametersPrivate variables in sub-programsVariable-length parameter listImproved max sub-programEmpty argument listAbout lexical (my) variablesUse strict compilation instructionsreturn operatorEllipsis and numberNon-scalar return valuePersisting private variablesExercisesFifth chapter input and outputReading standard inputInput from the diamond operatorCalling parametersOutput to standard outputjnprintf formatted outputArrays and printfFile handleOpen File HandleRead and wri
# commonly used in ACM: To determine whether the entire read process is over. (p280) while (CIN >> word) // read operation succeeded ...This method is inefficient and is more efficient in this way: "ACM Notes" No.4 http://www.cnblogs.com/fengyubo/p/4769254.html# Ifstream ReadOfstream WriteFStream Reading and writingFstream::open (s) // Open File Sfstream::close () // close File# Q: Why does C + + not put the file type into a built-in initialization of an object-like Cin, cout, Cerr? I
font s) change size a) change alignmentb) Toggle Bold i) Toggle italic u) Toggle UnderlineQ) quitQbye!A program should use the operator and the appropriate mask to ensure that the font ID and font size information are converted to the specified range.#include 7. Write a program that is identical to the functionality described in Exercise 6. Use a unsigned long to save the font information, and use the bitwise operator instead of the bit member to manage the information.#include This article is
The path to C ++ primer (fifth edition)-Chapter 4: expressions, C Language
[Disclaimer: All Rights Reserved. indicate the source for reprinting. Do not use it for commercial purposes. Contact mailbox: libin493073668@sina.com]
4.1 Basics
1. The expression is composed of one or more operation objects (operand). Evaluate the expression to get a result ). The literal value and variable are the simplest expres
The school textbooks are so rotten that they buy their own books.It was the beginning of the classic, the opening of the Startled me ~Nineth page ≯1.4/ch1_example2.html/1 Script>2 //Script block 23 document bgcolor="Red";4 Alert ("Second script block");5 Script>Run without passing, carefully examine the found1 document BgColor should be Document.bgcolorIf you say ". "Written" is a clerical error, then "bgcolor" in JavaScript is a beginner's mistake.HTML is not sensitive to capitalization, an
array element, not the array itself. Because the array length is ignored, it is particularly misleading if the array length is included in the parameter definition.When the compiler checks an argument associated with an array parameter, it checks that the argument is not the pointer, the type of the pointer, and the type of the array element, but does not check the length of the arrays.4.2 Array ArgumentsAs with other types, an array parameter can be defined as either a reference or a non-refer
does not support pop_front operations. These operations delete the specified element and return void.The return value of the Pop_front and Pop_back functions is not a deleted element value, but void. To get the deleted element value, you must call the front or back function before deleting the element.3.7.2 Delete an element within a containerThe erase operation does not check its parameters. The programmer must ensure that the scope of the iterator or iterator used as a parameter is valid.3.8
Problem:Reads a piece of text into a vector object, and each word is stored as an element in the vector. Put the Vector objectEach word is converted to uppercase. Outputs the converted elements in the vector object, with each 8 words being one line of output.Code:1#include 2#include 3 4 using namespacestd;5 6 intMain ()7 {8cout"Enter a text (Ctrl + Z end):"Endl;9vectorstring>Vecstr;Ten stringWord; One while(cin>>word) A { - Vecstr.push_back (word); - } the if(vecstr.size ()
cannot be dereferenced or self-increment.(4), other operations of the iteratorAnother pair of executable iterators is the comparison: with = = or! = operator to compare two iterators, if the two iterator objects point to the same element, they are equal, otherwise they are not equal.5.1 Standard library Bitset typeSome programs handle an ordered set of bits, each of which may contain a value of 0 (off) or 1 (on). A bit is a concise way to hold yes/no information (sometimes called a flag) for a
.8.1 EnumerationEnumerations provide an alternative way to define not only the set of integer constants, but also the aggregation of them into groups.1. Defining and Initializing enumerationsThe definition of an enumeration includes the keyword enum, followed by an optional enumeration type name, and a comma-separated list of enumeration members enclosed in curly braces.By default, the first enumeration member is assigned a value of 0, and each subsequent enumeration member assigns a value that
functions that call data in a function:The pointer is used if the data object is a built-in data type.If the data object is an array, you can only use pointersUse a reference or pointer if the data object is a structUse a reference if the data object is a class object2. Summary:When is it time to use pointers to pass parameters in C + + programming? Summarized as follows:(1) When you need to iterate through an array or frequently refer to its elements, this is more efficient than using the lowe
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.