integer int, reverse string

Source: Internet
Author: User

#import <Foundation/Foundation.h>

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

@autoreleasepool {

1. There are 123456789, how to put the number of each digit, starting at the end of a sequence into an array

(then the first element of this new array is 9, one time and so on) if you succeed, walk them out.

NSNumber *[email protected];

Nsarray *[email protected][@ "1", @ "2", @ "3", @ "4", @ "5", @ "6", @ "7", @ "8", @ "9"];

NSString *str=[nsstring stringwithformat:@ "%@", Num];

Nsmutablearray *mutarr=[nsmutablearray Array];

for (int i=8; i>=0; i--) {

Nsrange RANG0;

Rang0.location=i;

rang0.length=1;

NSString *str1=[[nsstring Alloc]init];

Str1=[str SUBSTRINGWITHRANGE:RANG0];

[Mutarr ADDOBJECT:STR1];

}

For (id xin in Mutarr) {

NSLog (@ "%@", Xin);

}

NSLog (@ "????????????????????????????????????????????????????????");

2. How to invert the string @ "abc123xyz789"

NSString *[email protected] "abc123.xyz789";

Nsmutablestring * mutstr1=[nsmutablestring string];

for (int i=0; i<strd.length; i++) {

Unichar C=[STRD Characteratindex:strd.length-i-1];

[Mutstr1 appendformat:@ "%c", c];

}

STR=MUTSTR1;

NSLog (@ "%@", str);

NSLog (@ "????????????????????????????????????????????????????????");

NSString *[email protected] "May 05, 2013";

Nsrange rang;

rang.location=0;

rang.length=4;

NSString *new=[time Substringwithrange:rang];

NSLog (@ "%@", new);

Nsrange rang1;

rang1.location=8;

rang1.length=2;

NSString *new1=[time Substringwithrange:rang1];

NSLog (@ "%@", New1);

Nsrange rang2;

rang2.location=8;

rang2.length=2;

NSString *new2=[time Substringwithrange:rang2];

NSLog (@ "%@", new2);

NSString *newstr=[new stringbyappendingformat:@ "-%@-%@", new1,new2];

NSLog (@ "%@", newstr);

}

return 0;

}

integer int, reverse string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.