• 考核7


    #import <Foundation/Foundation.h>

    int main(int argc, const char * argv[]) {

        @autoreleasepool {

        //1.以下是身份证号,输出身份证人的性别,名字

           // NSString *idCard=@210423198809040427;

            //身份证倒数#2位是偶数则为女生

            NSString *idCard=@"210423198809040427";

            NSRange strc=NSMakeRange(16, 1);

            NSRange stcr1=NSMakeRange(6, 4);

            NSString *sing=[idCard substringWithRange:strc];

            NSString *sing1=[idCard substringWithRange:stcr1];

            int ste=[sing intValue];

            int ste1=[sing1 intValue];

            if (ste%2==0) {

                NSLog(@"女 年龄:%d",2016-ste1);

            }else{

                NSLog(@"男 年龄:%d",2016-ste1);

            } 

        //2.将字典的key从Z->A排序,按排序后的key的顺序,输出value,将value按字符串输出

            NSDictionary *dict=@{@"R":@"e",

                                 @"T":@"e",

                                 @"D":@"b",

                                 @"S":@"u",

                                 @"K":@"a",

                                 @"A":@"s",

                                 @"O":@" ",

                                 @"N":@"p",

                                 @"B":@"b",

                                 @"J":@"u",

                                 @"F":@" ",

                                 @"U":@"t",

                                 @"H":@"l",

                                 @"E":@"j",

                                 @"Z":@"s",

                                 };

            NSDictionary *idc=[NSDictionary dictionaryWithDictionary:dict];

            NSArray *str1=[idc allKeys];

            str1=[str1 sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {

                return [obj2 compare:obj1];

            }];

            for (id str in str1) {

                NSLog(@"%@",str);

            }

            NSMutableArray *arr1=[[NSMutableArray alloc]init];

            for(id ser in str1){

                [arr1 addObject:[dict objectForKey:ser]];

            }

            NSLog(@"%@",arr1);

            NSString *Array=[arr1 componentsJoinedByString:@""];

            NSLog(@"%@",Array);    

        }

        return 0;

    }

  • 相关阅读:
    安装HDP时的报错信息
    K-近邻(KNN)算法
    linux复杂命令
    azkaban报错记录
    azkaban的安装部署
    安装centOS后要解决的问题
    AI之微信跳一跳
    Python的lambda
    关于在vim中的查找和替换
    cdh6.3.2 hue集成hbase
  • 原文地址:https://www.cnblogs.com/j-h-t-123-n/p/5116179.html
Copyright © 2020-2023  润新知