blob: 67c3d0b0202f901a6c07574de046c9824c9c3944 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#define DISTANCE 10
#define DOWNTIME 100000
int main(){
int i, j;
int num_rand; //for random color
int counter = 1; //change color when hits 5
srand(time(NULL));
while(1){
for(i = 0; i < DISTANCE; i++){
counter++;
for(j = 0; j < 15+i+1; j++){
printf("\b \b"); //backspace
}
for(j = 0; j < i; j++){
printf(" ");
}
if(counter == 5){
num_rand = (rand() % 7) + 1;
printf("\e[0;3%dm", num_rand);
counter = 1;
}
printf("Congratulations");
fflush(stdout);
usleep(DOWNTIME);
}
i--;
while(i > 1){
for(j = 0; j < 15+i; j++){
printf("\b \b"); //backspace
fflush(stdout);
}
i--;
for(j = 0; j < i; j++){
printf(" ");
}
printf("Congratulations");
fflush(stdout);
usleep(DOWNTIME);
}
}
printf("\n");
return 1;
}
|