zoukankan      html  css  js  c++  java
  • Utils

    -(NSString *)digitUppercaseWithMoney:(NSString *)money {

        NSMutableString *moneyStr=[[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%.2f",[money doubleValue]]];

        NSArray *MyScale=@[@"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"亿", @"", @"", @"", @"", @"", @"", @"" ]; NSArray *MyBase=@[@"", @"", @"", @"", @"", @"", @"", @"", @"", @""]; NSArray *integerArray = @[@"", @"", @"", @"", @"拾万", @"佰万", @"仟万", @"亿", @"拾亿", @"佰亿", @"仟亿", @"", @"拾兆", @"佰兆", @"仟兆"]; NSMutableString * M = [[NSMutableString alloc] init]; [moneyStr deleteCharactersInRange:NSMakeRange([moneyStr rangeOfString:@"."].location, 1)]; for(NSInteger i=moneyStr.length;i>0;i--) { NSInteger MyData=[[moneyStr substringWithRange:NSMakeRange(moneyStr.length-i, 1)] integerValue]; [M appendString:MyBase[MyData]]; //判断是否是整数金额

        if (i == moneyStr.length) { NSInteger l = [[moneyStr substringFromIndex:1] integerValue]; if (MyData > 0 && l == 0 ) { NSString *integerString = @""; if (moneyStr.length > 3) { integerString = integerArray[moneyStr.length-4]; } [M appendString:[NSString stringWithFormat:@"%@%@",integerString,@"元整"]]; break; } } if([[moneyStr substringFromIndex:moneyStr.length-i+1] integerValue]==0 && i != 1 && i != 2) { [M appendString:@"元整"]; break; } [M appendString:MyScale[i-1]]; } return M; }

    最怕你一生碌碌无为 还安慰自己平凡可贵
  • 相关阅读:
    123. Best Time to Buy and Sell Stock III (Array; DP)
    122. Best Time to Buy and Sell Stock II (Array;Greedy)
    121. Best Time to Buy and Sell Stock (Array;DP)
    38. Count and Say (String; DP)
    60. Permutation Sequence (String; Math)
    内存中的堆栈
    42. Trapping Rain Water (Array,stack; DP)
    84. Largest Rectangle in Histogram (Array, Stack; DP)
    85. Maximal Rectangle (Graph; Stack, DP)
    Effective C++ .44 typename和class的不同
  • 原文地址:https://www.cnblogs.com/fakeCoder/p/5135661.html
Copyright © 2011-2022 走看看