根据输入的内容打印
//比如 [obj printString:@"12345"];
1 1
2 22
3 3 3
44 4
5 5
*/
- (void)printString:(NSString *)string{
NSMutableString *muStr = [[NSMutableString alloc]init];
NSInteger length = string.length;
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
if (j == 0) {//第一列
[muStr appendFormat:@"%c",[string characterAtIndex:i]];
}else if (j + i == length -1){//这是副对角线的表示方法
[muStr appendFormat:@"%c",[string characterAtIndex:i]];
}else if (j == length - 1){//最后一列
[muStr appendFormat:@"%c",[string characterAtIndex: i]];
}
//这个是主对角戏
//比如 [obj printString:@"12345"];
1 1
2 22
3 3 3
44 4
5 5
*/
- (void)printString:(NSString *)string{
NSMutableString *muStr = [[NSMutableString alloc]init];
NSInteger length = string.length;
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
if (j == 0) {//第一列
[muStr appendFormat:@"%c",[string characterAtIndex:i]];
}else if (j + i == length -1){//这是副对角线的表示方法
[muStr appendFormat:@"%c",[string characterAtIndex:i]];
}else if (j == length - 1){//最后一列
[muStr appendFormat:@"%c",[string characterAtIndex: i]];
}
//这个是主对角戏