March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -2,27 +2,25 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
int num1, num2, i, j;
|
||||
NSMutableArray *arr;
|
||||
@autoreleasepool {
|
||||
int num1, num2;
|
||||
scanf("%d %d", &num1, &num2);
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
scanf("%d %d", &num1, &num2);
|
||||
NSLog(@"%d %d", num1, num2);
|
||||
|
||||
NSLog(@"%d %d", num1, num2);
|
||||
NSMutableArray *arr = [NSMutableArray arrayWithCapacity: (num1*num2)];
|
||||
// initialize it with 0s
|
||||
for(int i=0; i < (num1*num2); i++) [arr addObject: @0];
|
||||
|
||||
arr = [NSMutableArray arrayWithCapacity: (num1*num2)];
|
||||
// initialize it with 0s
|
||||
for(i=0; i < (num1*num2); i++) [arr addObject: [NSNumber numberWithInt: 0]];
|
||||
|
||||
// replace 0s with something more interesting
|
||||
for(i=0; i < num1; i++) {
|
||||
for(j=0; j < num2; j++) {
|
||||
[arr replaceObjectAtIndex: (i*num2+j) withObject: [NSNumber numberWithInt: (i*j)]];
|
||||
// replace 0s with something more interesting
|
||||
for(int i=0; i < num1; i++) {
|
||||
for(int j=0; j < num2; j++) {
|
||||
arr[i*num2+j] = @(i*j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// access a value: i*num2+j, where i,j are the indexes for the bidimensional array
|
||||
NSLog(@"%@", [arr objectAtIndex: (1*num2+3)]);
|
||||
[pool release];
|
||||
// access a value: i*num2+j, where i,j are the indexes for the bidimensional array
|
||||
NSLog(@"%@", arr[1*num2+3]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue