Psychs #4253(2007/11/19 11:45 GMT) [ Objective-C ] Rating2/2=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#import <Foundation/Foundation.h> NSString* toCol(int n) { NSMutableString* s = [NSMutableString stringWithFormat:@"%C", 'A' + n%26]; n /= 26; while (n > 0) { if (n <= 26) { [s insertString:[NSString stringWithFormat:@"%C", 'A' + n-1] atIndex:0]; break; } n -= 1; [s insertString:[NSString stringWithFormat:@"%C", 'A' + n%26] atIndex:0]; n /= 26; } return s; } int main() { NSAutoreleasePool *pool = [NSAutoreleasePool new]; int i; for (i=0; i<100; i++) { NSLog(@"%3d: %@", i+1, toCol(i)); } [pool release]; return 0; }
Rating2/2=1.00-0+
[ reply ]
Psychs
#4253()
[
Objective-C
]
Rating2/2=1.00
Rating2/2=1.00-0+
[ reply ]