Dark Horse programmer iOS Foundation eighth day

Source: Internet
Author: User

Reshape variable modifier change storage space for shaping variable short int a=4 short 2 byte%hdint 4 byte%d long 8 byte%ld long long 8 byte%lld shaping variable modifier Storage space for non-shaping variables int short long longlong change the symbol of a number signed unsigned not understand —————————————————————— change the symbol of a number: the original high To represent a number of positive and negative, now used to participate in computing the computer default is a signed number unsigned number with%u output————————————————————The Char type data stores the sizeof Monocular operator with abytesThe format gives the storage size of its operands.————————————————————————————The concept and classification of an "understanding" arraysame Typeof severalvariablesByOrderlyOrganized in the form ofCollectionAn array is a constructed type, an array element can be a basic data type, or a structure type   array's subscript   the dimension of an array  2. Categorized by stored content, four categories      numeric arrays: Storing values      Character Array: holds character ' a '      pointer array: hold pointer (address)      structure array: Data  3 that hold the struct type.   One-dimensional arrays by dimension   Two-dimensional arrays   three-dimensional arrays   Mastering one-dimensional array definitions and considerations  1. A one-dimensional array is introduced    : Stores the base data type int char float 2. Definition of one-dimensional array:      Array Usage flow: Define array---"Array initialization---" Use array      format as follows:     type specifier array name "constant expression (length of array)"      Array Type array name "array Length"      One-dimensional array: None of the elements of the array is an array      int a[3]//This array can only hold 3 Data of type int can only hold data of type int      considerations      1) The array length can be a constant or a constant expression: int a1[3+3]     3) Array name cannot have the same name as other variables      4) array length cannot be considered variable (C standard requirement)      5) The length of the array can be defined using a macro definition      6) When defining an array, you can also define normal variables:  int x,y,a7[4]  "Mastering" the initialization of one-dimensional arrays: Assigning an initial value to each element of an array  1. Initialization of one-dimensional arrays  2. Simultaneous initialization of the definition:   type specifier array name "constant expression" {value 1, value 2, ... };                 &NBSP                 (1) Simultaneous full initialization              &NBSP ;                           int a[3] = {1,2,3};                            ,         &N Bsp     int a2[] = {233,23,35};//The length of the array depends on the number of values in the following curly braces               & nbsp                     (2) define the simultaneous partial initialization of          &NB Sp                             the       INT  a1[3] = {1,2};//The third element is 0                         &N Bsp                   int a4[10]={[3]=23,[8]=34};//[3] indicates that an element with subscript 3 is assigned an initial value of 23 &nbs P &nbsp                          ,         &NB Sp     3. First define an array, then initialize              INT a5[4];//first define an array and initialize it with the subscript method  & nbsp               A5[0] = 12//assigns the first element of the array to 12                 A5[1] = 34 //If the array is not initialized, there are values, the values are random garbage values  //if partially initialized, the other elements in the array are 0  ————————————————————————   How a one-dimensional array is referenced   variable represents space in memory   array element is also variable   subscript: array element's number "0,n-1"   array Reference (Access): Array name "subscript"   Array traversal   In particular, the system does not assign a value of 0 to a part of an element that has not been initialized by using a first-defined post-initialization method, and if some of the elements are initialized, you will not be able to do so.   "Mastering" how a one-dimensional array is stored   stored:     1) The computer assigns a piece of   to the arrayContinuousStorage space 2) The array name represents the first address of the array, from the first address position, into the array's 1,2,3,n element 3) Each element occupies the same number of bytes (depending on the array type) 4) the address between the elements is contiguous memory address is the hexadecimal 0X beginning "mastering" one-dimensional array The element inside the address%p array is a sequential first defined array assigned to the first address of the array in the high address array name = = The address of the first element must be remembered: the array name is a constant (fixed does not allow modification), the first address of the array is stored—————————————————————————————— A method of calculating the length of one-dimensional array in "Mastering"Array length calculation method, super Important # include <stdio.h> int main (int argc, const char * argv[]) {int a1[]{1,2,4,5,6,3,3,3};  int len = sizeof (A1)/sizeof (int);   printf ("Len =%d\n", Len); return 0; }——————————————————————————————————————"Mastering" the cross-border problem of one-dimensional arraysAccess to the inaccessible space is very dangerous, the program will crash int main (int argc, const char * argv[]) {char a[2]={' h ', ' I '};  printf ("a[0] =%c\n", a[0]);  printf ("a[1] =%c\n", a[1]);  A[2]= ' s ';  printf ("a[2] =%c\n", a[2]); return 0; } ———————————————————————————— the array element as a function parameter to pass the value of the real parameter group element to the parameter,Value Passing"Mastering" the array name as function parameter 1. The type of the argument and the type of the parameter do not match--error 2. The length of the array can be different from the length of the 3-shape parameter group can not write 4. Array name as function parameter, the length of the array information is missing. Why is it fixed to 8? C language provisions, regardless of what type of data, the memory address of the data in memory accounted for 8 bytes of address accounted for 8 bytes————————————————————————————————————————[master] bubble sort, must test the topic, have to masterA sort algorithm, large number sinking, fractional ascent step (large number sinking) 1) compare adjacent elements

Dark Horse programmer iOS Foundation eighth day

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.