AC Small Notes

Source: Internet
Author: User

1: Use of basic library functions

The Rand () function can produce a random number between 0~32767.

A+rand ()% (b-a) can get a random number between [A, b].

2: Use of basic data types

You can use forced type conversions

Example: String str;

cin>>str;

int j=0;

while (Str[j]) {

Char c=str[j]+4; Here char uses the coercion type conversion.

cout<<c;

++j;

}

3: Simple use of the loop body

int change (int n) {

int m=0;

do{

m=m*10+n%10;

n/=10;

}while (n!=0); Here is the implementation of the N reverse.

return m;

}

Num=floor (num* 10.0 + 0.5)/10.0; Rounding is achieved.

AC Small Notes

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.