Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define MAXWORDLEN 200
  5. #define MAXNUMWORDS 200
  6. #define MAXGRIDCOLS 1000
  7. #define MAXGRIDROWS 1000
  8. #define TRUE 1
  9. #define FALSE 2
  10.  
  11. typedef struct words Words;
  12.  
  13. struct words{
  14. int x;
  15. int y;
  16. char letters[MAXWORDLEN];
  17. int used;
  18. };
  19.  
  20. //extern void printgrid(char grid, int numCols, int numRows,
  21. // char *words[MAXNUMWORDS][MAXWORDLEN]);
  22.  
  23. int main(void){
  24.  
  25. int numCols;
  26. int numRows;
  27. int numWords=0;
  28. int i=0, j=0;
  29. char grid[MAXGRIDCOLS][MAXGRIDROWS];
  30. char c;
  31.  
  32. //prompt user for game parameters
  33. printf("Enter number of rows and columns followed by a list of words: ");
  34.  
  35. //get the number of rows and columns from input
  36. if(scanf("%d%d", &numRows, &numCols)==2);
  37. //initialise grid
  38. for(i=0; i<numCols; i++){
  39. for(j=0; j<numRows; j++){
  40. grid[i][j]='.';
  41. }
  42. }
  43.  
  44. //get the words from input
  45. int breaker=1;
  46. while(breaker){
  47. while((c=getchar())!=EOF) {
  48. if (c=='\n'){
  49. if (j==0) {
  50. breaker=0;
  51. }
  52. break;
  53. }else{
  54. Words[i].letters[j]=c;
  55. j++;
  56. }
  57. }
  58. j=0;
  59. i++;
  60. numWords++
  61. }
  62.  
  63. //print the grid
  64. // printgrid(grid[MAXGRIDCOLS][MAXGRIDROWS], numCols, numRows,
  65. // *words[MAXNUMWORDS][MAXWORDLEN]);
  66.  
  67. for(i=0; i<numWords; i++){
  68. printf("%s", words[i].letters);
  69. }
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement