Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. void gotoxy (int row, int col)
  6. {
  7. printf("\n\033[%d;%dH", row, col);
  8. }
  9.  
  10. int main()
  11. {
  12. const int M=23, N=80;
  13. const int d=10000;
  14.  
  15. system("clear");
  16.  
  17. int way = 1;
  18. int offset = 1;
  19. while(offset <= N + M) {
  20. if(way){
  21. for(int i = 1; (i <= offset); i++) {
  22. if(i > M || (N - offset + i <= 0)) continue;
  23. gotoxy(i, N - offset + i);
  24. printf("*\n");
  25. usleep(d);
  26. }
  27. gotoxy((offset + 1 <= M) ? (offset + 1) : M , (offset + 1 <= M) ? N : N - (offset - M) - 1);
  28. printf("*\n");
  29. } else {
  30. for(int i = offset; (i > 0); i--) {
  31. if(i > M || (N - offset + i <= 0)) continue;
  32. gotoxy(i, N - offset + i);
  33. printf("*\n");
  34. usleep(d);
  35. }
  36. gotoxy((N - offset >= 1) ? 1 : (offset - N + 2), (N - offset >= 1) ? (N - offset) : 1);
  37. printf("*\n");
  38. }
  39.  
  40. usleep(d);
  41. way = !way;
  42. offset += 2;
  43. }
  44.  
  45. putchar('\n');
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement