Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* main.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2020/02/16 20:16:52 by igarcia- #+# #+# */
- /* Updated: 2020/02/16 23:29:24 by igarcia- ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include <stdio.h>
- #include <unistd.h>
- int entrada(int argc, char *argv[],int g_grind[6][6]);
- void salida(int g_grind[6][6]);
- void solver (int g_grind[6][6]);
- int g_grind[6][6];
- int main(int argc, char *argv[])
- {
- entrada(argc, argv, g_grind);
- solver(g_grind);
- salida(g_grind);
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* entrada.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2020/02/16 20:15:59 by igarcia- #+# #+# */
- /* Updated: 2020/02/16 23:31:04 by igarcia- ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include <unistd.h>
- #include <stdio.h>
- //int g_grind[6][6];
- int entrada(int argc, char *argv[], int g_grind[6][6])
- {
- int i;
- int j;
- if( argc == 2)
- {
- i = 0;
- j = 1;
- while( i <= 5)
- { while (j <= 4 && ((i == 0) || (i == 5)))
- {
- if(*argv[1] >= 48 && *argv[1] <= 56 )
- {
- g_grind[i][j] = *argv[1] - 48;
- argv[1]++;
- argv[1]++;
- j++;
- }
- else
- {
- write(2, "Error\n", 6);
- return (1);
- }
- }
- i++;
- j = 1;
- }
- i = 1;
- j = 0;
- while (j <= 5)
- { while (i <= 4 && (j == 0 || j == 5))
- {
- if (*argv[1] >= 48 && *argv[1] <= 56)
- {
- g_grind[i][j] = *argv[1] - 48;
- i++;
- argv[1]++;
- argv[1]++;
- }
- else
- {
- write(2, "Error\n", 6);
- return (1);
- }
- }
- j++;
- i = 1;
- }
- return (0);
- }
- else
- {
- write(2, "Error\n", 6);
- return(1);
- }
- }
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* salida.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: igarcia- <igarcia-@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2020/02/16 22:38:59 by igarcia- #+# #+# */
- /* Updated: 2020/02/16 23:30:54 by igarcia- ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include <unistd.h>
- //int g_grind[6][6];
- void salida(int g_grind[6][6])
- {
- int p;
- int i;
- int j;
- i = 1;
- j = 1;
- while(i <= 4)
- { if(j <= 4)
- {
- p = g_grind[i][j];
- p = p + 48;
- write(1, &p, 1);
- j++;
- }
- else
- {
- write(1, "\n", 1);
- i++;
- j = 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement