- 博客(15)
- 收藏
- 关注
原创 OC 自带排序方法
1.sortedArrayUsingComparator //给一个数组排序 - (NSArray *)sortedArrayUsingComparator:(NSComparator)cmptr //Returns an array that lists the receiving ordered set’s elements in ascending order, as determine
2015-01-19 11:47:36 751
原创 OC 自带方法 简绍 6 NSSet
1.set // 集 例子 Person * p = [[Person alloc] initWithName:@"阿顺" sex:@"男" age:30]; Person * p1 = [[Person alloc] initWithName:@"啊寿" sex:@"男" age:30]; Person * p2 = [[Pers
2015-01-19 08:55:26 306
原创 OC 自带方法 简绍 5 NSDictionary
1.字典 initWithObjectsAndKeys ; 初始化字典 dictionaryWithObjectsAndKeys : 初始化字典 dictionaryWithObjects forKeys: 1.1 NSDictionary * dic = [[NSDictionary alloc] initWithObjectsAndKeys:@"m
2015-01-18 21:18:44 347
原创 OC 自带方法 简绍 4 NSMutableArray
1.//NSMutableArray 继承自array 的可变数组 NSMutableArray * array = [[NSMutableArray alloc] initWithCapacity:1];// 这个数字代表了数组初始化有n个结构体的内存,若不够,再申请 n 个结构体内存. 例子 Person * p = [[Person alloc] initW
2015-01-18 18:05:10 320
原创 OC 自带方法 简绍 3 NSArray
1.initWithObjects // 例子 NSArray * array = [[NSArray alloc] initWithObjects:@"A", @"B",@"C" ,@"D" ,@"E" , nil]; NSLog(@"%@", array); // //arrayWithObjects 是initWithObjects 的便利构
2015-01-17 22:26:26 861
原创 OC 自带方法 简绍 2 NSMutableString
1. NSMutableString // 可以改变的string + (NSMutableString *)stringWithCapacity:(NSUInteger)capacity // NSMutableString * string = [NSMutableString stringWithFormat:@"蓝鸥"]; 2.appendString /
2015-01-17 21:36:37 776
原创 OC 自带方法 简绍 1 NSString
1. initWithFormat : 初始化一个 NString 类型 - (instancetype)initWithString:(NSString *)aString // Returns an NSString object initialized by copying the characters from another given string. 例子: int
2015-01-17 19:06:19 578
原创 利用OC类和可变数组制作简单的通讯录(基于控制台)
//1.新建一个TelBook类 //TelBook .h #import NSMutableArray * arr ; @interface TelBook : NSObject { NSString * _name; NSString * _sex; NSString * _tel; NSString * _address; N
2015-01-16 09:19:52 308
原创 优化冒泡排序
// int a[10] = {0}; // BOOL needAgin = YES; //先初始化还要继续排序 // for (int i = 0; i // a[i] = arc4random() % 10;// 随机赋值 // } // for (int i = 0; i // needAgin = NO;
2015-01-11 20:17:07 268
原创 冒泡排序和选择排序
// int a[] = {3 , -9 , 32 , 77 , 63 , -24 , 14 , 0 , 21 , 45}; // for (int i = 0; i // for (int j = 0; j // if (a[j] // int cup = a[j]; //
2015-01-11 20:03:29 301
原创 ACM 会场安排问题 最简单的解法
/*会场安排问题 ACM 第一行有1 个正整数k,表示有k 个待安排的活动。接下来的k 行中,每行有2 个正整数,分别表示k 个待安排的活动开始时间和结束时间。时间以0 点开始的分钟计。 希望使用尽可能少的会场. 设计算法求出 需要的最少会场数. */ // 这道题有很多种做法, 最流行的时贪心算法 // 但我发现了一个 特殊的做法 ,
2015-01-10 22:19:50 523
原创 C 中 & | ~ ^ 与 或 反 异或 的用法
//按位与 & , 有 0 为 0 , 全1 为 1 //作用 : 把某些二进制位清零, 需要清零的给 0 与 , 需要保留的给 1 与; int a = 0b00000011; int b = 0b00000010; int c = a & b; printf("%d\n", c); //下图是运行结果 //按位或
2015-01-10 22:16:07 650
转载 const 的用法
//const 用来修饰一个变量不能被修改 // const int a = 8; // printf("%d", a); // //const 修饰数组, 数组里面的每一个元素都不能修改 // const int array[3] = {1, 6, 8}; // //array[1] = 2; // zzz修改会提示报错 // //
2015-01-10 21:49:51 274
原创 交换两个数字最好的方法 C
// 异或 ^ 相同取0 不同 取 1; int a = 6 , b = 8; a = a ^ b; b = a ^ b; a = a ^ b; printf("%d %d", a, b); // 比较容易理解的是下面的一种方法 int a = 6 , b = 8; int c =
2015-01-08 22:46:02 319
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人