zoukankan      html  css  js  c++  java
  • 字符串转int

    #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;

    }

  • 相关阅读:
    预分频之三
    MySQL超时配置
    随机森林深入理解
    决策树算法——ID3
    指数平滑法
    最小二乘法的Java实现
    JS实战
    CSS布局实战
    Win7 Python开发环境搭建
    神经网络正向传播与反向传播公式
  • 原文地址:https://www.cnblogs.com/LiHai/p/5120207.html
Copyright © 2011-2022 走看看