zoukankan      html  css  js  c++  java
  • 考核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;

    }

  • 相关阅读:
    python random 随机选择操作
    分类预测,交叉验证调超参数
    7种炫酷HTML5 SVG液态水滴融合分解动画特效
    SAP WEBSERVICE Soap中RPC-style和Document-style
    Cocos2d-x 3.0final 终结者系列教程02-开发环境的搭建
    C#创建Excel文件并将数据导出到Excel文件
    某一天,忽然发现自己坚持不下去了。(无关计算机,仅仅是一些自己的困惑和感想)
    HDU4300-Clairewd’s message-KMP
    Java深入
    IOS UITextView光标位置在中间的问题
  • 原文地址:https://www.cnblogs.com/j-h-t-123-n/p/5116179.html
Copyright © 2011-2022 走看看