#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) { //Create 5 integer variables//on-Device CTRL + I//int a = 1;//int b = 2;//int c = 3;//int d = 4;//int f = 5;// //int n1 = 0;//int n2 = 0;//int n3 = 0;//int n4 = 0;//int n5 = 0;//int n6 = 0;//int N7 = 0;//int n8 = 0;//int N9 = 0;//int n10 = 0; //Array /*essence: Quickly define variable definitions for multiple identical data types: Data type array name [number of array elements] = {value 1, value 2, ..., value n}; Move: cmd ALT + [] array OK: Define variables of the same data type//NOTE 1: The index of the last array element is: Number of array elements-1//Note 2:C language, does not detect array subscript out of bounds*/ //Short array1[10] = {1,2,3,5}; //char array2[10] = {' A ', ' B '}; //int c[5] = {0}; //int d[] = {9, 5, 2, 7};//in the absence of a given array of elements, you can follow the pattern, at this time be sure to write a light rub all the initial value// //Create a float, an array of type Short,char, 10 elements each//int array[10] = {1,2,3,4,5,6,7,8,9,10};//for (int i = 0; i <; i++)// {//printf ("array[%d] =%d", I, Array[i]);// } //define 20 elements /*int a[10] = {0}; int b[10] = {0}; int c[10] = {0}; for (int i = 0; i < ten; i++) {A[i] = Arc4random ()% (40-20 + 1) + 20; printf ("a%d \ n", A[i]); } for (int i = 0; i < i++) {B[i] = A[i]; printf ("b =%d \ n", B[i]); } for (int i = 0; i < ten; i++) {c[i] = A[i] + b[i]; } *///int a[10] = {0};//int max = 0;//for (int i = 0; i < i++) {//A[i] = arc4random ()% (40-20 + 1) +;// // // //printf ("%d", A[i]);//max = max > A[i]? max:a[i];// }//printf ("Max is%d", max); //Bubble Sort /*int A[5] = {38,24,18,29,10}; 5 Elements The 1th trip compared 4 times, the 2nd trip compared 3 times, 3rd trip compared 2 times, 4th times compared 1 times int tem = 0; The i<4 here is not 5 to prevent the array element from crossing//Here is a trip, found the maximum//Outer loop Control comparison of the number of trips//outer loop-1 can be reduced without reducing, 1 is to improve the efficiency of the program for (int j = 0; j < 5-1; J + +) {//Inner loop control comparison number//inner loop, 1 must be reduced, objective: To prevent array subscript out-of-bounds//inner loop,-j can be reduced,-j is to improve efficiency for (int i = 0; i < 5-1-j; i++) {if (A[i] > A[i+1]) {//If the preceding interchange is greater than the following TEM = A[i]; A[i] = a[i+1]; A[I+1] = tem; }}} for (int i = 0; i < 5; i++) {printf ("%d", a[i]); } */ /*//Run the shortcut key cmd+r; Defines an integer array of 10 elements, [10, 30] random number, in ascending order, and then output int a[10] = {0}; int temp = 0; for (int i = 0; i < ten; i++) {A[i] = Arc4random ()% (30-10 + 1) + 10; }//for (int i = 0; i < 10-1; i++) {//for (int j = 0; J < 10-1-I; J + +) {//if (A[j] > A[j+1]) {//Temp = a[j];//A[j] = a[j+1];// A[J+1] = temp;//}//}//} for (int i = 0; i < 10-1; i++) {for (int j = 0; J < 10 -1-i; J + +) {if (A[j] < A[j + 1]) {temp = A[j]; A[J] = a[j + 1]; A[j + 1] = temp; }}} for (int i = 0; i < i++) {printf ("%d", a[i]); } */ //character Array//Defining Arrays /*char chararray[7] = {' n ', ' s ', ' d ', ' B ', ' B ', ' B ', ' s '}; Char str[] = "iPhone";//String, at the end of which there is an implied character ("%s \ n", str); Access to a single printf ("%c \ n", chararray[0]); for (int i = 0; i < 7; i++) {printf ("%c", Chararray[i]); } */ //string//A string is a character array, but a character array is not necessarily a string. //%s starts output from the first character of the string until it encounters A/s end output//Srrlen is the length of the string to see//1. Functions for calculating string lengths CharString1[] ="IPad"; intLength = (int) strlen (string1); printf ("%d \ n", length); //2. String copy function: strcpy (), copies the contents of the latter string to the previous string. //Note: The length of the latter string cannot exceed the previous string CharString2[] ="IPod"; //char string3[] = "Ipone";strcpy (string1, string2); printf ("%s\n", string1); printf ("%s\n", string2); //3. The concatenation function of the string: strcat (), stitching the latter string behind the previous string (starting with the position of the former string)strcat (string2, string2); printf ("%s\n", string2); //4. String comparison function: strcmp (), the previous string, followed by a string, one after the other, until the end of the search to the unequal character; Returns the difference between the previous string and the next string's unequal string (the character in the previous string, Subtract characters from the next string intresult =strcmp (string1, string2); printf ("%d \ n", result); return 0;}
iOS 4th days Group sort