Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- void gotoxy (int row, int col)
- {
- printf("\n\033[%d;%dH", row, col);
- }
- int main()
- {
- const int M=23, N=80;
- const int d=10000;
- system("clear");
- int way = 1;
- int offset = 1;
- while(offset <= N + M) {
- if(way){
- for(int i = 1; (i <= offset); i++) {
- if(i > M || (N - offset + i <= 0)) continue;
- gotoxy(i, N - offset + i);
- printf("*\n");
- usleep(d);
- }
- gotoxy((offset + 1 <= M) ? (offset + 1) : M , (offset + 1 <= M) ? N : N - (offset - M) - 1);
- printf("*\n");
- } else {
- for(int i = offset; (i > 0); i--) {
- if(i > M || (N - offset + i <= 0)) continue;
- gotoxy(i, N - offset + i);
- printf("*\n");
- usleep(d);
- }
- gotoxy((N - offset >= 1) ? 1 : (offset - N + 2), (N - offset >= 1) ? (N - offset) : 1);
- printf("*\n");
- }
- usleep(d);
- way = !way;
- offset += 2;
- }
- putchar('\n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement