C ++ problems encountered during learning, continuous updates, and

Source: Internet
Author: User

C ++ problems encountered during learning, continuous updates, and

Rounded up

Use the ceil function. Ceil (x) returns the smallest integer greater than x. For example, ceil (2.5) = 3 ceil (-2.5) =-2
Sort sorting header file

# Include <algorithm>

Array initialization Summary

Integer array initialization:

Char a [3] [4] = {0 };

Character array initialization:
Int B [3] [4] = {0 };

Boolean array initialization:
Bool c [5] = {0 };

Struct initialization:
Struct instruction {// defines the struct and stores commands.
Int head; // recognition command
Int d;
Int n; // additional instruction content
} Pro [1000] = {0}; // The storage program body, equivalent to RAM

After initialization, the value is 0.
(The char array is \ 000, the int array is 0, and the bool array is false. In this example, each member value of all elements in the struct is 0)

Use of sort () Functions

 

Like qsort (), sort () sorts specified parts of the array. Qsort () only uses fast sorting, and sort () uses hybrid sorting. In contrast, sort () is faster.

Sort () functions are commonly used in the form of two parameters and three parameters.

1. Two parameters: sort (array name, last address of the array); // example: sort (a + 1, a + n + 1 ); is for a [1]... a [n + 1] is sorted in ascending order by default. To change the sorting order, you need to write another comparison function.

2. Three parameters: sort (array name, last address of the array, comparison function );

For example:

bool cmp(const int a,const int b){    return a<b;}sort(a+1,a+10+1,cmp);

That is, sort a [1]... a [n + 1] in ascending order.



Problems encountered in learning c:

You should use a graphical program written in C language. It should be BGI error. Graphical programs in C language seem very troublesome. I used to see it in a book occasionally. It seems to be called "C language image programming", and I cannot remember it. A very old book.
I found some materials that should be useful to you.
Www.hackhome.com/infoview/article_0000759.html

Problems encountered in C Language Learning

1. The number of digits of int is related to the platform. Here you can use short to get the same (16 bit) as that of Tan Shu)
2. compilation platform related. tan's book is the result of compilation under TC, and different compilers have different numerical processing mechanisms. that's why you got the correct results. Tan's textbooks are also correct. the platform and environment you use are different.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.