百分率でtrueかfalseを返すプログラム

中学生の時に四苦八苦していた覚えのある問題である。
多分これで良いのではないだろうか?
in C


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <memory.h>

#define TRUE 1
#define FALSE 0

const int tas = 101;

int percent(int a)
{
int t = rand() % 100;
/*
if(t < a) return TRUE;
return FALSE;
*/

if(t >= a) return FALSE;
return TRUE;
}

int main(){

int table[tas],tf[2];
size_t i,j,count;
memset(table,0,sizeof(table));
memset(tf,0,sizeof(tf));

count = 1024 * 64;
for(i=0;i<count;i++){
int t = rand() % tas;
if(t > 100) return -1;
table[t]++ ;
}
for(i=0;i<tas;i++){
printf("table[%d] = %d\n",i,table[i]);
}
printf("//////////////////////////\n");
for(i=0;i<count;i++)
{
if(0==percent(100)) return -2;
if(1==percent(0)) return -3;
tf[percent(50)]++;
}

for(i=0;i<2;i++){
printf("tf[%d] = %d\n",i,tf[i]);
}
memset(table,0,sizeof(table));
memset(tf,0,sizeof(tf));
for(i=0;i<tas;i++){

for(j=0;j<count;j++){
int t= percent(i);
tf[t]++;
}

{

double dtf[2],temp;
temp = (double)count;
temp /= 100;
for(j=0;j<2;j++){
dtf[j] = (double)tf[j];
dtf[j] /= temp;
}

printf("%02d percentage false = %f / true = %f\n",
i,dtf[0],dtf[1]);
}
memset(tf,0,sizeof(tf));
}

#ifdef _DEBUG
system("PAUSE");
#endif
return 0;
}

><