Thread: Similar to boggle

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    1

    Similar to boggle

    Need help to edit this code to allow user to find words in the grid that are touching horizontally, vertically, and diagonally adjacent.
    For example, the board:
    Q W E R T
    A S D F G
    Z X C V B
    Y U A O P
    G H J K L
    contains the magic words WAS, WAXY, JOB.
    [COLOR=#3D3D3D][FONT=&quot]insert
    Code:
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    
    int lx;
    int ly;
    char grid[10][10];
    int z;
    int j;
    
    int main()
    {
      // declare array with alphabet
      char alphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
        'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't', 'u',
        'v', 'w', 'x', 'y', 'z'
      };
    
      printf("Insert the width (Lx) and height (Ly) of the grid \n");
      scanf("%d %d", &lx, &ly);
    
      for (z = 0; z < lx; z++) {
        for (j = 0; j < ly; j++) {
          // print letters instead of dots
          grid[z][j] = alphabet[rand() % 26];
        }
      }
      for (z = 0; z < lx; z++) {
        for (j = 0; j < ly; j++) {
          printf("%c", grid[z][j]);
        }
        printf("\n");
      }
    }
    Last edited by Salem; 04-23-2019 at 11:04 AM. Reason: Removed crayola

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    So how do you know what a valid word is?

    Do you know about recursion yet?

    Meh, cross-posted here as well -> Similar to boggle game - C++ Forum
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boggle Game Help
    By tatsu in forum C Programming
    Replies: 5
    Last Post: 04-16-2017, 10:49 PM
  2. Programming Boggle in C++ using a time function
    By tnau in forum C++ Programming
    Replies: 1
    Last Post: 07-21-2015, 04:29 PM
  3. How similar are C# and C++?
    By MilleniumFalcon in forum Tech Board
    Replies: 21
    Last Post: 03-09-2014, 02:30 PM
  4. Boggle game.
    By Desolation in forum Game Programming
    Replies: 5
    Last Post: 08-03-2007, 01:52 AM
  5. Boggle board help
    By PuhFENDanT in forum C++ Programming
    Replies: 2
    Last Post: 06-16-2003, 10:43 AM

Tags for this Thread