Strange note-taking sauce

Source: Internet
Author: User

Excerpt from Rokua:

//0x3f3f3f3f can also bring us an unexpected bonus: if we want to clear an array, we usually use code like memset (A,0,sizeof (a)) to do it (convenient and efficient)

But when we want to assign an array all to infinity (such as the initialization of the adjacency matrix when solving the graph theory problem), you can't use the memset function to write loops.

(It's really painful to write these unimportant code.)

//We know that this is because the memset is in bytes, and it is able to clear 0 of the array because 0 of each byte is 0

//Well now, if we set infinity to 0x3f3f3f3f, then miracles happen, and every byte of 0x3f3f3f3f is 0x3f!

So to set a memory to infinity, we only need memset (A,0x3f,sizeof (a)).

http://blog.csdn.net/u011394362/article/details/39135107

Strange note-taking sauce

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.