include stdio include stdlib include string include time define get_ti

 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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define get_time() (long)((clock()/(float)CLOCKS_PER_SEC)*1000)
#define STR_LENGTH 80
#define HEIGHT 5
void set_timer(long msc) {
long start = get_time();
while ((get_time() - start) < msc);
}
int main(int argc, char** argv) {
int j, b, char_index, str_len;
char *string = (char*) malloc(sizeof (char)*STR_LENGTH), curr_char;
printf("Input string: ");
scanf("%s", string);
system("cls||clear");
printf("%s", string);
set_timer(250);
str_len = strlen(string);
while (str_len) {
curr_char = string[(char_index = --str_len / 2)];
for (j = char_index; string[j] != '\0'; j++) string[j] = string[j + 1];//смещение строки
for (j = 1; j <= HEIGHT; j++) {
system("cls||clear");
printf("%s", string);
for (b = 1; b <= j; b++) printf("%c", '\n');
for (b = 0; b < char_index; b++) printf("%c", ' ');
printf("%c", curr_char);
set_timer(250);
}
}
free(string);
return 0;
}