C ++ notes

Source: Internet
Author: User

// Pay attention to some of the remarks. # Include

 
  
# Include

  
   
// 1 --- the difference between cstring and string: int main () {using namespace std; cout <"Please Enter a string: \ n"; string word; cin> word; // char temp; // 3 --- int I, j; // for (I = 0, j = word. size ()-1; I <= j; ++ I, -- j) for (I = 0, j = word. length ()-1; I <= j; ++ I, -- j) // 2 --- word. size () word should be an array. word. length () and word. size () indicates the length of the array. because the array subscript starts from 0. therefore,-1 is required to prevent the subscript from crossing the border {char temp; // The internal declaration temp is allocated and released in each loop, which is slower than the declaration before the for loop body, when the cycle ends, the/char temp = word [I]; // 3 --- // char temp = word [I]; // 3 --- temp = word [I]; word [I] = word [j]; word [j] = temp;} cout <

   

    

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.