Advertisement
Guest User

fdppp

a guest
Aug 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. char *rush_top_bottom(char *str, int x, char right, char left)
  4. {
  5. char *string;
  6. int j;
  7.  
  8. j = 0;
  9. *str = left;
  10. str++;
  11. while (j < x - 2)
  12. {
  13. *str = '-';
  14. str++;
  15. j++;
  16. }
  17. if (x >= 2)
  18. {
  19. *str = right;
  20. str++;
  21. }
  22. *str = '\n';
  23. str++;
  24. return (str);
  25. }
  26.  
  27. char *rush00(int x, int y)
  28. {
  29. char *tmp;
  30. char *str;
  31. int i;
  32. int j;
  33.  
  34. str = (char*)malloc(sizeof(char) * (x + 1) * y);
  35. tmp = str;
  36. j = 0;
  37. if (x <= 0 || y <= 0)
  38. return (0);
  39. str = rush_top_bottom(str, x, 'o', 'o');
  40. while (j < y - 2)
  41. {
  42. i = 0;
  43. *str = '|';
  44. str++;
  45. while (i < x - 2)
  46. {
  47. *str = ' ';
  48. str++;
  49. i++;
  50. }
  51. if (x >= 2)
  52. {
  53. *str = '|';
  54. str++;
  55. }
  56. *str = '\n';
  57. str++;
  58. j++;
  59. }
  60. if (y >= 2)
  61. str = rush_top_bottom(str, x, 'o', 'o');
  62. return (tmp);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement