ホームに戻る
 乱数発生

#include <stdio.h>
#include <time.h>

// 乱数発生関数
unsigned int xor128(void) { 
  static unsigned int x = 123456789;
  static unsigned int y = 362436069;
  static unsigned int z = 521288629;
  static unsigned int w = 88675123; 
  unsigned int t;
 
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
}

int main(){
  srand((unsigned)time(NULL));

  printf("\n%d\n", rand() % 10);

  return 0;
}

inserted by FC2 system