#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define BUFSIZE 160 int main() { char buf[BUFSIZE]; double y; int i, col; srand(time(NULL)); y = 1.0; for (i = 0; i < 1000; i++) { y = y * (0.9 + 0.2 * ((double)rand() / RAND_MAX)); memset(buf, ' ', BUFSIZE); buf[40] = '|'; col = y * 40.0; if (col < BUFSIZE) { buf[col] = '*'; } printf("%.*s\n", BUFSIZE, buf); } return 0; }
Standard input is empty
| * *| * | * * | *| |* *| * | * *| | * |* | * | * |* | * | * | * |* *| * | * | * | * | * | |* |* | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | *| |* |* *| | * | * |* | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * |* *| * | * | *| | * * * | * | *| * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * |