Advertisement
Guest User

rush00

a guest
Sep 5th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 12.35 KB | None | 0 0
  1. /* ************************************************************************** */
  2. /*                                                                            */
  3. /*                                                        :::      ::::::::   */
  4. /*   ft_putchar.c                                       :+:      :+:    :+:   */
  5. /*                                                    +:+ +:+         +:+     */
  6. /*   By: stheo <marvin@42.fr>                       +#+  +:+       +#+        */
  7. /*                                                +#+#+#+#+#+   +#+           */
  8. /*   Created: 2018/09/01 14:18:02 by stheo             #+#    #+#             */
  9. /*   Updated: 2018/09/01 15:39:13 by stheo            ###   ########.fr       */
  10. /*                                                                            */
  11. /* ************************************************************************** */
  12.  
  13. #include <unistd.h>
  14.  
  15. void    ft_putchar(char c)
  16. {
  17.     write(1, &c, 1);
  18. }
  19. /* ************************************************************************** */
  20. /*                                                                            */
  21. /*                                                        :::      ::::::::   */
  22. /*   main.c                                             :+:      :+:    :+:   */
  23. /*                                                    +:+ +:+         +:+     */
  24. /*   By: stheo <marvin@42.fr>                       +#+  +:+       +#+        */
  25. /*                                                +#+#+#+#+#+   +#+           */
  26. /*   Created: 2018/09/01 14:19:22 by stheo             #+#    #+#             */
  27. /*   Updated: 2018/09/01 18:08:31 by stheo            ###   ########.fr       */
  28. /*                                                                            */
  29. /* ************************************************************************** */
  30.  
  31. void    ft_putchar(char c);
  32. void    rush(int x, int y);
  33.  
  34. int main()
  35. {
  36.     rush(5, 5);
  37.     return (0);
  38. }
  39. /* ************************************************************************** */
  40. /*                                                                            */
  41. /*                                                        :::      ::::::::   */
  42. /*   rush00.c                                           :+:      :+:    :+:   */
  43. /*                                                    +:+ +:+         +:+     */
  44. /*   By: nguillet <marvin@42.fr>                    +#+  +:+       +#+        */
  45. /*                                                +#+#+#+#+#+   +#+           */
  46. /*   Created: 2018/09/01 15:17:15 by nguillet          #+#    #+#             */
  47. /*   Updated: 2018/09/01 18:03:43 by stheo            ###   ########.fr       */
  48. /*                                                                            */
  49. /* ************************************************************************** */
  50.  
  51. #include<unistd.h>
  52.  
  53. void ft_putchar(char c);
  54.  
  55. void    ft_aff(int x, int y, int x1, int y1)
  56. {
  57.     while (y <= y1)
  58.     {
  59.         while (x <= x1)
  60.         {
  61.             if (x == 1 && y == 1) ft_putchar('o');              // afficher premier caractere
  62.             if (x > 1 && y == 1 && x != x1) ft_putchar('-');        // affiche les caracteres de la premiere ligne
  63.             if (x == 1 && y > 1 && y != y1) ft_putchar('|');        // affiche les carateres  de la premiere colone
  64.             if (x > 1 && y > 1 && x != x1 && y != y1) ft_putchar(' ');// affiche les caracteres espace
  65.             if (x == x1 && y == 1 && x > 1) ft_putchar('o');        // affiche le dernier caractere de la ligne pour y = 1
  66.             if (y == y1 && x == 1 && y > 1) ft_putchar('o');        // affiche le dernier caractere de la colone pour x = 1
  67.             if (y == y1 && x == x1 && y != 1 && x != 1) ft_putchar('o');// affiche le dernier caractere des dernieres lignes/colones
  68.             if (x == x1 && y > 1    && y != y1 && x > 1)ft_putchar('|');// affiche les caracteres de la derniere colone
  69.             if (y == y1 && x > 1 && x != x1 && y > 1)ft_putchar('-');// affiche les caracteres de la derniere ligne
  70.             x++;
  71.         }
  72.         ft_putchar('\n');
  73.         x = 1;
  74.         y++;
  75.     }
  76. }
  77.  
  78. void rush(int x, int y)
  79. {
  80.     if (x <= 0 || y <= 0)
  81.         return ;
  82.     ft_aff(1, 1, x, y);
  83. }
  84. /* ************************************************************************** */
  85. /*                                                                            */
  86. /*                                                        :::      ::::::::   */
  87. /*   rush01.c                                           :+:      :+:    :+:   */
  88. /*                                                    +:+ +:+         +:+     */
  89. /*   By: nguillet <marvin@42.fr>                    +#+  +:+       +#+        */
  90. /*                                                +#+#+#+#+#+   +#+           */
  91. /*   Created: 2018/09/01 15:17:15 by nguillet          #+#    #+#             */
  92. /*   Updated: 2018/09/01 18:05:32 by stheo            ###   ########.fr       */
  93. /*                                                                            */
  94. /* ************************************************************************** */
  95.  
  96. #include<unistd.h>
  97.  
  98. void ft_putchar(char c);
  99.  
  100. void    ft_aff(int x, int y, int x1, int y1)
  101. {
  102.     while (y <= y1)
  103.     {
  104.         while (x <= x1)
  105.         {
  106.             if (x == 1 && y == 1) ft_putchar('/');              // afficher premier caractere
  107.             if (x > 1 && y == 1 && x != x1) ft_putchar('*');        // affiche les caracteres d         e la premiere ligne
  108.             if (x == 1 && y > 1 && y != y1) ft_putchar('*');        // affiche les carateres  de la premiere colone
  109.             if (x > 1 && y > 1 && x != x1 && y != y1) ft_putchar(' ');// affiche les caracteres espace
  110.             if (x == x1 && y == 1 && x > 1) ft_putchar('\\');       // affiche le dernier caractere de la ligne pour y = 1
  111.             if (y == y1 && x == 1 && y > 1) ft_putchar('\\');       // affiche le dernier caractere de la colone pour x = 1
  112.             if (y == y1 && x == x1 && y != 1 && x != 1) ft_putchar('/');// affiche le dernier caractere des dernieres lignes/colones
  113.             if (x == x1 && y > 1    && y != y1 && x > 1)ft_putchar('*');// affiche les caracteres de la derniere colone
  114.             if (y == y1 && x > 1 && x != x1 && y > 1)ft_putchar('*');// affiche les caracteres de la derniere ligne
  115.             x++;
  116.         }
  117.         ft_putchar('\n');
  118.         x = 1;
  119.         y++;
  120.     }
  121. }
  122.  
  123. void rush(int x, int y)
  124. {
  125.     if (x <= 0 || y <= 0)
  126.         return ;
  127.     ft_aff(1, 1, x, y);
  128. }
  129. /* ************************************************************************** */
  130. /*                                                                            */
  131. /*                                                        :::      ::::::::   */
  132. /*   rush02.c                                           :+:      :+:    :+:   */
  133. /*                                                    +:+ +:+         +:+     */
  134. /*   By: nguillet <marvin@42.fr>                    +#+  +:+       +#+        */
  135. /*                                                +#+#+#+#+#+   +#+           */
  136. /*   Created: 2018/09/01 15:17:15 by nguillet          #+#    #+#             */
  137. /*   Updated: 2018/09/01 18:05:08 by stheo            ###   ########.fr       */
  138. /*                                                                            */
  139. /* ************************************************************************** */
  140.  
  141. #include<unistd.h>
  142.  
  143. void ft_putchar(char c);
  144.  
  145. void    ft_aff(int x, int y, int x1, int y1)
  146. {
  147.     while (y <= y1)
  148.     {
  149.         while (x <= x1)
  150.         {
  151.             if (x == 1 && y == 1) ft_putchar('A');              // afficher premier caractere
  152.             if (x > 1 && y == 1 && x != x1) ft_putchar('B');        // affiche les caracteres d         e la premiere ligne
  153.             if (x == 1 && y > 1 && y != y1) ft_putchar('B');        // affiche les carateres  de la premiere colone
  154.             if (x > 1 && y > 1 && x != x1 && y != y1) ft_putchar(' ');// affiche les caracteres espace
  155.             if (x == x1 && y == 1 && x > 1) ft_putchar('A');        // affiche le dernier caractere de la ligne pour y = 1
  156.             if (y == y1 && x == 1 && y > 1) ft_putchar('C');        // affiche le dernier caractere de la colone pour x = 1
  157.             if (y == y1 && x == x1 && y != 1 && x != 1) ft_putchar('C');// affiche le dernier caractere des dernieres lignes/colones
  158.             if (x == x1 && y > 1    && y != y1 && x > 1)ft_putchar('B');// affiche les caracteres de la derniere colone
  159.             if (y == y1 && x > 1 && x != x1 && y > 1)ft_putchar('B');// affiche les caracteres de la derniere ligne
  160.             x++;
  161.         }
  162.         ft_putchar('\n');
  163.         x = 1;
  164.         y++;
  165.     }
  166. }
  167.  
  168. void rush(int x, int y)
  169. {
  170.     if (x <= 0 || y <= 0)
  171.         return ;
  172.     ft_aff(1, 1, x, y);
  173. }
  174. /* ************************************************************************** */
  175. /*                                                                            */
  176. /*                                                        :::      ::::::::   */
  177. /*   rush03.c                                           :+:      :+:    :+:   */
  178. /*                                                    +:+ +:+         +:+     */
  179. /*   By: nguillet <marvin@42.fr>                    +#+  +:+       +#+        */
  180. /*                                                +#+#+#+#+#+   +#+           */
  181. /*   Created: 2018/09/01 15:17:15 by nguillet          #+#    #+#             */
  182. /*   Updated: 2018/09/01 18:04:43 by stheo            ###   ########.fr       */
  183. /*                                                                            */
  184. /* ************************************************************************** */
  185.  
  186. #include<unistd.h>
  187.  
  188. void ft_putchar(char c);
  189.  
  190. void    ft_aff(int x, int y, int x1, int y1)
  191. {
  192.     while (y <= y1)
  193.     {
  194.         while (x <= x1)
  195.         {
  196.             if (x == 1 && y == 1) ft_putchar('A');              // afficher premier caractere
  197.             if (x > 1 && y == 1 && x != x1) ft_putchar('B');        // affiche les caracteres d         e la premiere ligne
  198.             if (x == 1 && y > 1 && y != y1) ft_putchar('B');        // affiche les carateres  de la premiere colone
  199.             if (x > 1 && y > 1 && x != x1 && y != y1) ft_putchar(' ');// affiche les caracteres espace
  200.             if (x == x1 && y == 1 && x > 1) ft_putchar('C');        // affiche le dernier caractere de la ligne pour y = 1
  201.             if (y == y1 && x == 1 && y > 1) ft_putchar('A');        // affiche le dernier caractere de la colonepour x =1
  202.             if (y == y1 && x == x1 && y != 1 && x != 1) ft_putchar('C');// affiche le dernier caractere des dernieres lignes/colones
  203.             if (x == x1 && y > 1    && y != y1 && x > 1)ft_putchar('B');// affiche les caracteres de la de  rniere colone
  204.             if (y == y1 && x > 1 && x != x1 && y > 1)ft_putchar('B');// affiche les caracteres de la derniere ligne
  205.             x++;
  206.         }
  207.         ft_putchar('\n');
  208.         x = 1;
  209.         y++;
  210.     }
  211. }
  212.  
  213. void rush(int x, int y)
  214. {
  215.     if (x <= 0 || y <= 0)
  216.         return ;
  217.     ft_aff(1, 1, x, y);
  218. }
  219. /* ************************************************************************** */
  220. /*                                                                            */
  221. /*                                                        :::      ::::::::   */
  222. /*   rush04.c                                           :+:      :+:    :+:   */
  223. /*                                                    +:+ +:+         +:+     */
  224. /*   By: nguillet <marvin@42.fr>                    +#+  +:+       +#+        */
  225. /*                                                +#+#+#+#+#+   +#+           */
  226. /*   Created: 2018/09/01 15:17:15 by nguillet          #+#    #+#             */
  227. /*   Updated: 2018/09/01 18:06:02 by stheo            ###   ########.fr       */
  228. /*                                                                            */
  229. /* ************************************************************************** */
  230.  
  231. #include<unistd.h>
  232.  
  233. void ft_putchar(char c);
  234.  
  235. void    ft_aff(int x, int y, int x1, int y1)
  236. {
  237.     while (y <= y1)
  238.     {
  239.         while (x <= x1)
  240.         {
  241.             if (x == 1 && y == 1) ft_putchar('A');              // afficher premier caractere
  242.             if (x > 1 && y == 1 && x != x1) ft_putchar('B');        // affiche les caracteres d         e la premiere ligne
  243.             if (x == 1 && y > 1 && y != y1) ft_putchar('B');        // affiche les carateres  de la premiere colone
  244.             if (x > 1 && y > 1 && x != x1 && y != y1) ft_putchar(' ');// affiche les caracteres espace
  245.             if (x == x1 && y == 1 && x > 1) ft_putchar('C');        // affiche le dernier caractere de la ligne pour y = 1
  246.             if (y == y1 && x == 1 && y > 1) ft_putchar('C');        // affiche le dernier caractere de la colonepour x =1
  247.             if (y == y1 && x == x1 && y != 1 && x != 1) ft_putchar('A');// affiche le dernier caractere des dernieres lignes/colones
  248.             if (x == x1 && y > 1    && y != y1 && x > 1)ft_putchar('B');// affiche les caracteres de la de  rniere colone
  249.             if (y == y1 && x > 1 && x != x1 && y > 1)ft_putchar('B');// affiche les caracteres de la derniere ligne
  250.             x++;
  251.         }
  252.         ft_putchar('\n');
  253.         x = 1;
  254.         y++;
  255.     }
  256. }
  257.  
  258. void rush(int x, int y)
  259. {
  260.     if (x <= 0 || y <= 0)
  261.         return ;
  262.     ft_aff(1, 1, x, y);
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement