いいアイデアが思い浮かびません。
どなたかいいアイデアはないでしょうか?
こんな感じで、どうでしょうか?
unsigned get_seed(char* s) { unsigned ret = 0; while (*s++) { ret = (ret << 1) + *s; } return ret; } int main(void) { char* s = "a-kuma3 has answered this question"; unsigned seed = get_seed(s); srand(seed); ... }
こんな感じで、どうでしょうか?
unsigned get_seed(char* s) { unsigned ret = 0; while (*s++) { ret = (ret << 1) + *s; } return ret; } int main(void) { char* s = "a-kuma3 has answered this question"; unsigned seed = get_seed(s); srand(seed); ... }
CRC32を使うというのはどうでしょうか。
http://ja.wikipedia.org/wiki/%E5%B7%A1%E5%9B%9E%E5%86%97%E9%95%B7%E6%A4%9C%E6%9F%BB
ここの終わりの方にコードもあります。
コメント(0件)