Introduction to ACM Small summary

Source: Internet
Author: User

1.SCANF and printf use significantly less time than cin and cout consume.

The 2.Gets () function is used to read a whole line of functions, can be infinitely read, do not judge the upper limit, encountered the end of the return, use caution.

The Getchar () function can read one character at a time, and this character can be a carriage return. Putchar () corresponds to the output of one character.

3.EOF is a predefined constant, equal to -1.

Both 4.Strcmp () and compare () are used to compare two strings, returning 0the same time, which returns 1larger than the latter ( Strcmp returns a positive number ), the former smaller than the latter returns -1 (strcmp Returns a negative number ).

Fractional Precision control in 5.c++:

① header file #include <iomanip>

②cout<<setiosflags (ios::fixed) <<setprecision ( number of decimal digits controlled ) <<number<< Endl;

6.C language can be entered in a set format ( very useful )!

For example, you need to enter 2016/2/14 This format

The input is done directly with scanf ("%d/%d/%d", &a,&b,&c) . Other methods I'm not.

7. When considering leap years, it is sometimes considered whether the month exceeds 2 months.

8. Learn to use the assert macro. #include <assert.h> assert (x>=0) executes when x satisfies a non-negative, otherwise terminates abnormally.

9.long long in the C language input scanf ("%i64d", &n). when output printf ("%lld", a) .

10. The string includes the Terminator ' + '. strlen () The function does not count the bytes of '% '. Strlen () Need header file string.h .

11. Ranking problem, commonly used structure.

12. The only way to add a space in the middle of the result:

Int b=0;

Printf (b++?) "%d": "%d", a);

The former has a space and the latter does not.

13.c++ uses a mathematical function to refer to the header file math.h , directly with sqrt (x).

Introduction to ACM Small summary

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.