C
XORを3回すると入れ替えできます。 #define swap(a,b) a^=b^=a^=b このマクロは完璧じゃない点に注意(副作用あり)
int dayofweek( int y, /* y > 1752 or so */ int m, /* 1 int d) { static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; int w; if (m y--; } w = (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7; if ((w % 7) == 0) { /* 0 = Sunday */ w = 7; } return…