Objective-C Implementation of semi-search, selection of sorting, Bubble sorting and quick sorting, and bubble objective-c
Objective-C Implementation of semi-search, selection of sorting, Bubble sorting, and quick sorting
-(IBAction) zheBanChaZhao :( id) sender {NSMutableArray * allObj = [[NSMutableArray alloc] init]; int base = 0; int findY = arc4random () % 1000; for (int I = 1; I <100; I ++) {int tmpX = arc4random () % 10; base + = tmpX; [allObj addObject: [NSNumber numberWithInt: base];} NSMutableString * mulStr = [[NSMutableString alloc] init]; NSInteger count = [allObj count]; for (NSInteger I = 0; I
TmpInt) {low = mid + 1;} else {index = mid; break;} if (index! =-1) {NSLog (@ "% ld digit found", index);} else {NSLog (@ "\ n not found ");}} -(IBAction) xuanZhePaiXu :( id) sender {NSMutableArray * allObj = [[NSMutableArray alloc] init]; for (int I = 1; I <30; I ++) {int tmpX = arc4random () % 100; [allObj addObject: [NSNumber numberWithInt: tmpX];} NSMutableString * mulStr = [[NSMutableString alloc] init]; NSInteger count = [allObj count]; for (NSInteger I = 0; I
[JNum integerValue]) {[allObj exchangeObjectAtIndex: j withObjectAtIndex: I] ;}} mulStr = [[NSMutableString alloc] init]; for (NSInteger I = 0; I
= RightIndex) {// return if the array length is 0 or 1;} NSInteger I = leftIndex; NSInteger j = rightIndex; // record benchmark number NSInteger key = [array [I] integerValue]; while (I <j) {/***** first, start from j on the Right To Find A value smaller than the base number. ***/while (I <j & [array [j] integerValue]> = key) {// if it is larger than the benchmark number, continue to search for j --;} // if it is smaller than the benchmark number, swap the small value to the position I, array [I] = array [j]; /***** when a value smaller than the benchmark value is found on the right side, start from I and find the value larger than the reference number ***/while (I <j & [array [I] integerValue] <= key) {// if it is smaller than the benchmark number, continue to search for I ++;} // if it is larger than the benchmark number, place the searched cursor to the j position array [j] = array [I];} // place the baseline number in the correct position array [I] = @ (key ); // [self kuaiSu: array withLeftIndex: leftIndex andRightIndex: I-1] on the left of the benchmark number; // [self kuaiSu: array withLeftIndex: I + 1 andRightIndex: rightIndex];}