16
Jul
#include<Foundation/Foundation.h>

@interface Sort:NSObject

{

}

-(void)sort:(NSMutableArray *)elt;

@end

@implementation Sort

-(void)sort:(NSMutableArray *)elt

{

int i;

[elt sortUsingSelector: @selector (compare:)];

NSLog(@"\n%@",elt);

}

@end

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

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSMutableArray *savingArray = [[NSMutableArray alloc] init];

int i,n,a;

id show;

show=[[Sort alloc] init];

NSLog(@"Enter the number of numbers");

scanf("%d",&n);

NSLog(@"Enter the numbers");

for(i=0;i<n;i++)

{

scanf("%d",&a);

NSNumber *nu = [[NSNumber alloc] initWithInt:a];

[savingArray addObject:nu];

}

[show sort:savingArray];

[show release];

[pool drain];

}


Posted by on 16 Jul 2010 by antonyjoemathew in Objective C

Add reply

*