#import <Foundation/Foundation.h>

 

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

    @autoreleasepool {

 

        NSString *result1=[[NSString alloc]init];

        NSString *str2=[[NSString alloc]init];

        NSString *str=[[NSString alloc]initWithString:@"158"];

        NSString *str1=[[NSString alloc]initWithString:@"39"];

        int num=[str intValue];

        int num1=[str1 intValue];

        int result=num-num1;

        NSString *strResult1 = [NSString stringWithFormat:@"%d",result];

        

        NSLog(@"  %d ",result);

        

    //  3取出符串“123-456-789-000”中的数字部分,组成一个新的字符串输出

        //NSString *newstr3=[str3 stringByReplacingOccurrencesOfString:@"-" withString:@"" ]; 找到符号  替换成后一个

        NSString *str3=@"123-456-789-000";

        NSString *newstr3=[str3 stringByReplacingOccurrencesOfString:@"-" withString:@"" ];

        NSLog(@"%@",newstr3);

    //4放四个十进制三位数到一个数组中,然后按从小到大排序后组成一个新的数组

        NSArray *arr=@[@"3",@"2",@"1"];

        

        NSArray *arrNew=[arr sortedArrayUsingSelector:@selector(compare:)];

        

        NSLog(@"%@",arrNew);      

    }

    return 0;

}

 

相关文章:

  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2021-12-27
  • 2022-02-17
  • 2021-07-27
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2021-06-22
  • 2021-07-25
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案