# Import
Int main (int argc, const char * argv []) {# pragma mark ---------- array // The array is a container, same data type // construction type // int a [3] = {5, 2, 0}; // type // int [3]; // variable name //; // Initial Value // {5, 2, 0}; // int a [4] = {9, 8, 2.5}; // float B [6] = {3.14 }; // char c [3] = "abc"; // char d [3] = {'A', 'B', 'C '}; // BOOL e [4] = {YES, NO}; // a [0] + a [1] Operation Array subscript value assignment // There is a type modifier before, represents an array, without a type modifier, representing subscript // 1. generate an array containing 20 elements. The value of the array is between 30 and 70, and obtain the sum of the elements of the array. // int sum = 0, a [20] = {0 }; // for (int I = 0; I <20; I ++) {// a [I] = arc4random () % 41 + 30; // printf ("% d", a [I]); // sum = sum + a [I]; //} // printf ("\ nsum = % d", sum); // 2. copy // int a [20] = {0}, B [20] = {0}; // for (int I = 0; I <20; I ++) {// a [I] = arc4random () % 41 + 30; // printf ("% d", a [I]); // B [I] = a [I]; //} // printf ("\ n"); // for (int j = 0; j <20; j ++) {// printf ("% d", B [j]); //} // 3. generate two arrays and add the subscript elements of the two arrays to the third array. // int a [10] = {0}, B [10] = {0 }, c [10] = {0}; // for (int I = 0; I <10; I ++) {// a [I] = arc4random () % (40-20 + 1) + 20; // B [I] = arc4random () % (40-20 + 1) + 20; // c [I] = a [I] + B [I]; // printf ("% d + % d = % d \ n", a [I], B [I], c [I]); //} // printf ("\ n"); // for (int j = 0; j <10; j ++) {// printf ("% d", B [j]); //} // printf ("\ n "); // for (int j = 0; j <10; j ++) {// printf ("% d", c [j]); ///} # pragma mark -------------- 1 // note, // 1, the system does not check whether the subscript of the array element is out of bounds. During programming, the array subscript must not be out of bounds // 2, an array is a whole. It cannot directly participate in operations. It can only process a single element. It usually uses an array and uses a loop (the loop is generated for an array) // scanf ("% d", & a); // getchar () print 123def. The result is 1 // printf (""), print the result of 123def as 123/*** read data from the keyboard buffer * // int a [10] = {0}; // for (int I = 0; I <10; I ++) {// a [I] = arc4random () % 31; // printf ("% 2d", a [I]); ///} // for (int I = 0; I <10-1; I ++) {// for (int j = 0; j <10-1-i; j ++) {// if (a [j]> a [j + 1]) {// int temp = a [j]; // a [j] = a [j + 1]; // a [j + 1] = temp; ///} // printf ("\ n"); // for (int I = 0; I <10; I ++) {// printf ("%-2d", a [I]); //} // int a [10] = {0 }; // for (int I = 0; I <10; I ++) {// a [I] = arc4random () % (40-20 + 1) + 20; // printf ("% d", a [I]); //} // for (int I = 0; I <10-1; I ++) {// for (int j = 0; j <10-1-i; j ++) {// if (a [j]> a [j + 1]) {// maxa [I] // int temp = a [j]; // a [j] = a [j + 1]; // a [j + 1] = temp; //} // printf ("\ n"); // for (int I = 0; I <10; I ++) {// printf ("% d", a [I]); //} // strlen ("hello "); # pragma mark -------------- 2 // String Length: hello, String Length: 5 // printf ("% lu", strlen ("hello ")); // string space, for example, char [10] = "hello" string space, 10; // char c [] = "hello"; // printf ("% lu ", sizeof (c); // for (int I = 0; I
1) {// printf ("\ n % s greater than % s", str1, str2); //} else if (result = 0) {// printf ("% s equals % s", str1, str2); //} else {// printf ("\ n % s less than % s", str1, str2); // strlen // strcmp // strcat // strcpy // find the number of spaces in the string // char str [50] = "I love iOS, I want an iPhone5s "; // int I = 0, count = 0; // while (str [I]! = '\ 0') {// char c = str [I]; // if (c = '') {// count ++; ///} // I ++; //} // printf ("% d", count); # pragma mark -------------- 4 // reverse the character and solve the problem! // Any switch must define a third-party temp char str1 [] = "hello"; char str2 [5] = ""; long length = strlen (str1 ); // printf ("% lu", length); printf ("% lu", sizeof (str1); // long length = strlen (str1 ); // printf ("% lu", length); // int I = 0; // while (str1 [I]! = '\ 0') {// char temp = str1 [I]; // str1 [I] = str2 [I]; // str2 [I] = temp; ////} // printf ("% s", str2); // for (int I = 0; I
) {// <# Statements #> //} // # pragma mark -------------- 5 absolute value // # pragma mark -------------- 6for loop // # pragma mark -------------- 7 job