Created
April 20, 2011 03:48
-
-
Save akiraak/930294 to your computer and use it in GitHub Desktop.
配列の添字にマイナスを使って参照
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int funcname(int i){ | |
static const int minus[]={-2, -1}; | |
static const int plus[]={0, 1}; | |
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) | |
assert(i >= -ARRAYSIZE(minus) && i < ARRAYSIZE(plus)); | |
return plus[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment