Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1.  
  2. #include <unistd.h>
  3.  
  4. void    ft_putchar(char c)
  5. {
  6.     write(1, &c, 1);
  7. }
  8.  
  9. void    ft_print(int width, char a, char b, char c)
  10. {
  11.     int w_counter;
  12.  
  13.     w_counter = 0;
  14.     while (w_counter < width)
  15.     {
  16.         if (w_counter == 0)
  17.             ft_putchar(a);
  18.         else if (w_counter == width - 1)
  19.             ft_putchar(b);
  20.         else
  21.             ft_putchar(c);
  22.         w_counter += 1;
  23.     }
  24.     ft_putchar('\n');
  25. }
  26.  
  27. void    rush(int width, int height)
  28. {
  29.     int h_counter;
  30.  
  31.     h_counter = 0;
  32.     while (h_counter < height)
  33.     {
  34.         w_counter = 0;
  35.         if (h_counter == 0)
  36.         {
  37.             ft_print(width, 'A', 'C', 'B');
  38.         }
  39.         else if (h_counter == height - 1)
  40.         {
  41.             ft_print(width, 'C', 'A', 'B');
  42.         }
  43.         else
  44.         {
  45.             ft_print(width, 'B', 'B', ' ');
  46.         }
  47.         h_counter += 1;
  48.     }
  49. }
  50.  
  51. int     main(void)
  52. {
  53.     rush(1, 1);
  54.     rush(10, 10);
  55.     rush(1, 1);
  56.     rush(1, 5);
  57.     return (0);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement