Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* test.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: squiana <[email protected]> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2019/07/14 20:44:39 by squiana #+# #+# */
- /* Updated: 2019/07/14 21:17:14 by ckumera ### ########.fr */
- /* */
- /* ************************************************************************** */
- int test_line(char **tab, char nb, int i)
- {
- int j;
- j = 0;
- while (j < 9)
- {
- if (tab[i][j] == nb)
- return (0);
- j++;
- }
- return (1);
- }
- int test_column(char **tab, char nb, int j)
- {
- int i;
- i = 1;
- while (i <= 9)
- {
- if (tab[i][j] == nb)
- return (0);
- i++;
- }
- return (1);
- }
- int test_block(char **tab, int i, int j, char nb)
- {
- int x;
- int y;
- x = -1;
- if (i <= 3)
- i = 1;
- else if (i <= 6)
- i = 4;
- else if (i <= 9)
- i = 7;
- j = j - (j % 3);
- while (++x < 3)
- {
- y = -1;
- while (++y < 3)
- {
- if (tab[i][j] == nb)
- return (0);
- j++;
- }
- j = j - 3;
- i++;
- }
- return (1);
- }
- int test_symbol(int n, char **tab)
- {
- int i;
- int j;
- i = 0;
- if (n == 10)
- {
- while (++i <= 9)
- {
- j = 0;
- while (tab[i][j])
- {
- if ((tab[i][j] <= 48 || tab[i][j] > 57) && tab[i][j] != 46)
- return (0);
- j++;
- }
- if (j != 9)
- return (0);
- }
- return (1);
- }
- else
- return (0);
- }
Add Comment
Please, Sign In to add comment