IOS getting started tutorial (2)-Control Flow

Source: Internet
Author: User

IOS getting started tutorial (2)-Control Flow

Int main () {// 2. control Flow // 2.1 if statement // 1. if (expression) {}// 2.if( expression) {} else {}// 3. there can be 0 or more else if, and the last else can also omit if (expression) {cx} else if (expression) {} else {} // 2.2 switch statement // 1. single-line code switch (n) {case 0: printf ("000000"); break; case 1: printf ("111111"); break; case 2: printf ("222222"); break; default: break;} // 2. multi-line code switch (n) {case 0: {printf ("000000"); printf ("000000"); break;} case 1: {printf ("111111 "); printf ("000000"); break;} case 2: {printf ("222222"); printf ("000000"); break;} default: break ;} // 2.3 Cycle Structure // 1. while loop while (expression) {// dosomething} // 2. for Loop for (int I = 0; I
 
  
2) {return 0 ;}// 2.4 goto statement, which is rarely used or not used. // It is usually used in a nested loop for (int I = 0; I
  
   
5) {goto outer ;}}outer: printf ("nested"); // 3. array // 3.1 defines the array tyoe arrayName [lenth]; // when the array is used to calculate the address, the element address = the first address + Memory occupied by the array variable * index // 3.2 array value assignment int arr [2] = {1, 2}; // 3.3 Use the array printf ("% d", arr [0]); // traverse the basic array element for (int I = 0, length = sizeof (arr) /sizeof (arr [0]); I
   
    

Append an example of two-digit array.

# Include
     
      
# Include
      
       
# Include
       
        
# Define NO_CHESS "success" # define BLACK_CHESS "●" # define WHITE_CHESS "○" # define BOARD_SIZE 15 // define the size of the chessboard static char * board [BOARD_SIZE] [BOARD_SIZE]; // define a two-dimensional array to act as the void initBoard () {int I, j; // assign each element to the Board Output for (I = 0; I
        
         


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.