all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
25
Task/Symmetric-difference/Objective-C/symmetric-difference.m
Normal file
25
Task/Symmetric-difference/Objective-C/symmetric-difference.m
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSSet* setA = [NSSet setWithObjects:@"John", @"Serena", @"Bob", @"Mary", @"Serena", nil];
|
||||
NSSet* setB = [NSSet setWithObjects:@"Jim", @"Mary", @"John", @"Jim", @"Bob", nil];
|
||||
|
||||
// Present our initial data set
|
||||
NSLog(@"In set A: %@", setA);
|
||||
NSLog(@"In set B: %@", setB);
|
||||
|
||||
// Get our individual differences.
|
||||
NSMutableSet* notInSetA = [NSMutableSet setWithSet:setB];
|
||||
[notInSetA minusSet:setA];
|
||||
NSMutableSet* notInSetB = [NSMutableSet setWithSet:setA];
|
||||
[notInSetB minusSet:setB];
|
||||
|
||||
// The symmetric difference is the concatenation of the two individual differences
|
||||
NSMutableSet* symmetricDifference = [NSMutableSet setWithSet:notInSetA];
|
||||
[symmetricDifference unionSet:notInSetB];
|
||||
|
||||
// Present our results
|
||||
NSLog(@"Not in set A: %@", notInSetA);
|
||||
NSLog(@"Not in set B: %@", notInSetB);
|
||||
NSLog(@"Symmetric Difference: %@", symmetricDifference);
|
||||
|
||||
[pool drain];
|
||||
Loading…
Add table
Add a link
Reference in a new issue