帝王にifなどいらぬ!
■ このスレッドは過去ログ倉庫に格納されています
0070デフォルトの名無しさん
2006/03/17(金) 20:12:08int cond_lt (int a, int b) {
return ((a - b) >> 31) & 1;
}
int cond_zero (int a) {
return (~(a ^ -a) >> 31) & 1;
}
int zero (const char* s1, const char* s2) {
return 0;
}
int one (const char* s1, const char* s2) {
return 1;
}
int minus_one (const char* s1, const char* s2) {
return -1;
}
int strcmp (const char* s1, const char* s2) {
int a = *s1 & 0xff;
int b = *s2 & 0xff;
int (*table[8]) (const char*, const char*) = {
strcmp, zero, minus_one, minus_one, one,
0, 0, 0 // この3パターンは有り得ない
};
return (*table[
(cond_zero(a)) |
(cond_lt(a,b) << 1) |
(cond_lt(b,a) << 2)]) (s1 + 1, s2 + 1);
}
■ このスレッドは過去ログ倉庫に格納されています