Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* main.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2020/02/16 20:16:52 by igarcia- #+# #+# */
  9. /* Updated: 2020/02/16 23:29:24 by igarcia- ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12.  
  13. #include <stdio.h>
  14. #include <unistd.h>
  15.  
  16. int entrada(int argc, char *argv[],int g_grind[6][6]);
  17. void salida(int g_grind[6][6]);
  18. void solver (int g_grind[6][6]);
  19.  
  20. int g_grind[6][6];
  21.  
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25. entrada(argc, argv, g_grind);
  26.  
  27.  
  28.  
  29. solver(g_grind);
  30.  
  31. salida(g_grind);
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. /* ************************************************************************** */
  45. /* */
  46. /* ::: :::::::: */
  47. /* entrada.c :+: :+: :+: */
  48. /* +:+ +:+ +:+ */
  49. /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
  50. /* +#+#+#+#+#+ +#+ */
  51. /* Created: 2020/02/16 20:15:59 by igarcia- #+# #+# */
  52. /* Updated: 2020/02/16 23:31:04 by igarcia- ### ########.fr */
  53. /* */
  54. /* ************************************************************************** */
  55.  
  56. #include <unistd.h>
  57. #include <stdio.h>
  58.  
  59. //int g_grind[6][6];
  60.  
  61. int entrada(int argc, char *argv[], int g_grind[6][6])
  62. {
  63. int i;
  64. int j;
  65.  
  66. if( argc == 2)
  67. {
  68. i = 0;
  69. j = 1;
  70. while( i <= 5)
  71. { while (j <= 4 && ((i == 0) || (i == 5)))
  72. {
  73. if(*argv[1] >= 48 && *argv[1] <= 56 )
  74. {
  75. g_grind[i][j] = *argv[1] - 48;
  76. argv[1]++;
  77. argv[1]++;
  78. j++;
  79. }
  80. else
  81. {
  82. write(2, "Error\n", 6);
  83. return (1);
  84. }
  85.  
  86. }
  87. i++;
  88. j = 1;
  89. }
  90. i = 1;
  91. j = 0;
  92.  
  93. while (j <= 5)
  94. { while (i <= 4 && (j == 0 || j == 5))
  95. {
  96. if (*argv[1] >= 48 && *argv[1] <= 56)
  97. {
  98. g_grind[i][j] = *argv[1] - 48;
  99. i++;
  100. argv[1]++;
  101. argv[1]++;
  102. }
  103. else
  104. {
  105. write(2, "Error\n", 6);
  106. return (1);
  107. }
  108. }
  109. j++;
  110. i = 1;
  111. }
  112. return (0);
  113. }
  114. else
  115. {
  116. write(2, "Error\n", 6);
  117. return(1);
  118. }
  119. }
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. /* ************************************************************************** */
  133. /* */
  134. /* ::: :::::::: */
  135. /* salida.c :+: :+: :+: */
  136. /* +:+ +:+ +:+ */
  137. /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
  138. /* +#+#+#+#+#+ +#+ */
  139. /* Created: 2020/02/16 22:38:59 by igarcia- #+# #+# */
  140. /* Updated: 2020/02/16 23:30:54 by igarcia- ### ########.fr */
  141. /* */
  142. /* ************************************************************************** */
  143.  
  144. #include <unistd.h>
  145.  
  146. //int g_grind[6][6];
  147.  
  148. void salida(int g_grind[6][6])
  149. {
  150. int p;
  151. int i;
  152. int j;
  153. i = 1;
  154. j = 1;
  155.  
  156. while(i <= 4)
  157. { if(j <= 4)
  158. {
  159. p = g_grind[i][j];
  160. p = p + 48;
  161. write(1, &p, 1);
  162. j++;
  163. }
  164. else
  165. {
  166. write(1, "\n", 1);
  167. i++;
  168. j = 1;
  169. }
  170. }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement