Algorithm Programming question Language notes

Source: Internet
Author: User

1. Power

 
# Include <math. h>//Header filePow (A, B );//A ^ B

 

2. bool

 
# Include <stdbool. h>//Header files need to be added when bool type is used in C.

 

3. String operations

# Include <String. H>//Header file CharA [20], B [20]; Strcpy (A, B );//Copy string B toLength= Strlen ();//LengthStrcmp (A, B );//String comparison: Compares the characters in a and B one by one, and continues to compare the next character. The operation is terminated at the same time and the difference size is returned.

 

4. Fast sorting in C library functions

 # include 
    
    ///  
     header file  
     int  num [
     100  
    ];  
     int  CMP (
     const  
     void  * a, 
     const  
     void  * B) 
    ///  
     comparison functions  
    { 
     return  * (
     int  *) A-* (
     int  * 
    ) B;} qsort (Num,  
     100 , 
     sizeof  (Num [
     0 ]), CMP); 
     //  
     call the sorting function  
   

 

5. Input and Output

Enter a string with spaces

 
 CharCh [100]; Gets (CH );

 

Output Format

 
 IntA =12; Printf ("% 05d", );//Right alignment. The width is 5, which is not enough to be filled with 0. The output is 00012.Printf ("%-07d", );//Left alignment, 7 in width, not 0 fill, output: 1200000

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.