Add tags

Add tags to the following comment
 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;
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...