#include
#include
#include
#define NCALLS 1000
#define NCOLS 8
#define NLINES 3
int main(void)
{
int i, val;
long begin, diff, end;
double median = RAND_MAX / 2, above_cnt=0, below_cnt=0, differences;
begin = time(NULL);
srand(time(NULL));
for (i = 1; i <=NCALLS; ++i) {
val = rand();
if (val < median)
below_cnt += 1;
else if (val>median)
above_cnt += 1;
if (i <= NCOLS*NLINES) {
printf("%7d", val);
if (i%NCOLS == 0)
printf("\n");
}
else if (i == NCOLS*NLINES + 1)
printf("%7s\n\n", ".....");
}
end = time(NULL);
diff = end - begin;
differences = above_cnt - below_cnt;
printf("%s%ld\n%s%ld\n%s%ld\n%s%.10f\n%s%ld\n\n",
" end time:", end,
" begin time:", begin,
" elapsed time:", diff,
" time for each call:", (double)diff / NCALLS,
" differences:",differences);
scanf_s("%d", &i);
return 0;
}