Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- void ft_putchar(char c)
- {
- write(1, &c, 1);
- }
- void ft_print(int width, char a, char b, char c)
- {
- int w_counter;
- w_counter = 0;
- while (w_counter < width)
- {
- if (w_counter == 0)
- ft_putchar(a);
- else if (w_counter == width - 1)
- ft_putchar(b);
- else
- ft_putchar(c);
- w_counter += 1;
- }
- ft_putchar('\n');
- }
- void rush(int width, int height)
- {
- int h_counter;
- h_counter = 0;
- while (h_counter < height)
- {
- w_counter = 0;
- if (h_counter == 0)
- {
- ft_print(width, 'A', 'C', 'B');
- }
- else if (h_counter == height - 1)
- {
- ft_print(width, 'C', 'A', 'B');
- }
- else
- {
- ft_print(width, 'B', 'B', ' ');
- }
- h_counter += 1;
- }
- }
- int main(void)
- {
- rush(1, 1);
- rush(10, 10);
- rush(1, 1);
- rush(1, 5);
- return (0);
- }
- /*
- This is a piece of code I was able to write myself after completing that group project on the harder pyramid building project I had. Albeit, it is a simple piece of code, but given I am just starting out in C and programming again, I am proud of it because to me it was the first time things clicked and showed me how code can do tasks extremely fast. The idea of the program was simply to print out a pattern box of respective size based off user input and the box would determine whether it is a side, corner or interior to fill it with a respective character. I felt that I wrote it efficiently made it very readable by others. Users would be able to switch out the characters of choice based on how they want the box to look. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement