days floatmoney=0, Ave; while(n -) { money=money+0.8*N; Day++; N*=2;//N each x2} Ave=money/Day ;printf ("I'm a jerk, I buy apples every day.") I am Tao Tao I bought%d apples ", N/2);//Because n exits the loop because the n> or =100 is because the number of X is 2 so I have to/2 to get the amount of the Tao to buy apples printf ("The result is%.6f", Ave); return 0;} I'm a jerk. I buy apples every day. I'm Tao Tao, I bought 64 apples.//The result is 16.799999Code for the preparation of level
For historical reasonsCodeIt is not entirely written using. net. At this time, mixed programming with the previous C ++ code is very important. I recently encountered such a problem and briefly described the method as follows.
Call simple C ++ Functions
The general idea of calling C ++ functions in
();}
VoidDisplay_int () {obj. display (2 );}}
G ++ test. cpp-fPIC-shared-o libtest. soThis method is troublesome but can solve the problem. Note that there will still be an extern "C" later. Otherwise, the constructed dynamic link library does not have the symbol tables of these functions.
ImportCtypesso = ctypes. CDLL ("./libtest. so") so. display () so. display_int (1)
The running result is as follows:^ [Root @:~ /Projects/nugg
Readers may suspect that something as simple as an if, a for, a while, a goto, or a switch should also be about programming style, is it a fuss?
I really find that many programmers write expressions and basic statements in the wrong way, and I have made similar mistakes myself.
Both expressions and statements belong to the C++/C phrase structure syntax. They se
if the global variable is to be referenced, it is placed in the *.h and declared with extern.
2. If the declaration of a function has a keyword extern, it simply implies that the function may be defined in another source file, with no other effect. That is, the following two function declarations do not differ:
extern void Print_externifo (); and Voidprint_externifo ();
The use of extern in functions:
If the C/cpp file that defines the function d
The diagram shows a framework for how to organize memory in a typical C + + program. The instructions in the program (which are stored at the bottom level) and global variables are often stored statically (static area), which is located at the beginning of the near machine address space where the address number is smaller. The amount of memory allocated in the zone does not change during program operation.The highest address area in memory represents
automatically executed, it is equivalent to the root of the tree. If some rules are not in this tree
Not automatically executed. For example, the Clean Action in the example above (these actions can be called)
6. Write outstanding makefile filesWriting makefile does not mean writing a beautiful makefile.Variables (equivalent to macros) in makefile: Name =... reference $ (name)The purpose of using variables makes makefile clear and easy to maintain.
7. Make's automatic derivation FunctionFor exa
When using C + + programming, sometimes to use the third-party library, and the first party libraries is given in C, it is strange that the C file has been added to the project, the header file has been introduced, the compilation still appearsUndefined referenceThe problem here, the third party
//////////////////////////////////////// //////////////////////////////////////// ///////////*Title: use asynchronous Socket programming in C # to implement the C/S communication architecture of TCP network services (I) ---- Basic Library sectionWhen I see TcpListener and TcpClient in. NET, I am very happy, that is, the communication mode I want.However, we can s
Analyze the following code:
/* = Sum. H = */
# Ifndef sum_h# Define sum_h# Include
Int sum (int A, int B );
# Endif;
/* = Sum. c = */
# Include "sum. H"
Int sum (int A, int B){Int c = A + B;Return C;}
/* = Main. cpp = */
# Include "sum. H"
Void Mian (){
Cout
}
The above three files are called and compiled successfully, but the following problems occur during ex
(addrserver,0,sizeof(Addrserver));//Initialize Amemcpy ( (ADDRSERVER.SIN_ADDR), host->h_addr, host->h_length);//Set IP -addrserver.sin_family = af_inet;//Set the version number -Addrserver.sin_port = htons ((unsigned Short) server_port);//set the port number the - //connect .... Initiating a link to the server - if(Connect (SOCKFD,structSOCKADDR *) addrserver,sizeof(structsockaddr ))) - { +printf"Connect error!\n"); -Exit1); + } Aprintf"Connection Server succeeded Connec success...\n\n");Next
"Chicken Peck Rice C + + Programming Primer Series" series of technical Articles to organize collectionCollection of Chicken Peck rice C + + Programming Primer series for individuals and netizens to learn C + + reference1 Chicken Peck Rice: Introduction to
"Chicken Peck Rice C + + Programming Primer Series" series of technical Articles to organize collectionCollection of Chicken Peck rice C + + Programming Primer series for individuals and netizens to learn C + + reference1 Chicken Peck Rice: Introduction to
embedded Linux C Language (11)--C language modular programming Modular programming of C language The so-called modular programming means that a program contains multiple source files (. c
distributions are often used, and other distributions include bernoulli_distribution,exponential_distribution and chi_distribution. Detailed descriptions can be found in the C + + programming Language. The return value of the integer distribution is the closed interval [A:B], and the return value of the real (floating-point) distribution is the open interval [a:b].By default, each time the program runs, th
Mm_text
1px
Mm_lometric
0.1mm
Mm_himetric
0.01mm
Mm_loenglish
0.01 inch
Mm_hienglish
0.001 inch
Mm_twips
1/1440 inch
Mm_isotropic
User-defined value, but the X and y directions are equal (equal)
Mm_anisotropic
User-defined values, but the X and Y directions are arbitrary
The mapping mode is set by a member function Setmapmode
vector container, and outputs their opposite number#include #include#include#include#includeusing namespacestd;intMain () {Const intN =5; Vectorint> S (N);//Container for(inti =0; i ) Cin>>S[i]; Transform (S.begin (), S.end (), Ostream_iteratorint> (cout," "), negateint>()); coutEndl; return 0;}//implementation of the transform algorithm, no more knocking in the machinetemplateclassInputiterator,classOutputiterator,classUnaryfunction>Outputiterator Transform (inputiterator First, inputitera
Hybrid programming in Apple system development (1): mutual calls between Objective-C and C ++, and mutual calls between flex and jsFirst, OC calls the C ++ code. Create an Objective-C Project and create the c ++ file MyCppFile. hp
Preliminary Analysis of the Structure in C language programming, analysis of the C language structure
The C-language struct is one of the powerful functions of C and a favorable condition for C ++ language derivation. In fact, whe
1. Introduction
When C/C ++ and Assembly mixed programming are required, there are two processing strategies:
If the Assembly Code is short, you can directly embed the assembly language in the C/C ++ source file to implement mixed prog
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.