Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 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 wordef wordslist;
  12.  
  13. struct wordef {
  14. char letters[MAXWORDLEN];
  15. int used;
  16. };
  17.  
  18. //extern void printgrid(char grid, int numCols, int numRows,
  19. // char *words[MAXNUMWORDS][MAXWORDLEN]);
  20.  
  21. int main(void){
  22.  
  23. int numCols;
  24. int numRows;
  25. int numWords=0;
  26. int i=0, j=0, k=0;
  27. wordslist words[999];
  28.  
  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. int getout = 1;
  44.  
  45. getchar();
  46. int b = 0;
  47. int r = 0;
  48. int breaker = 1;
  49. while(breaker) {
  50.  
  51. while((c = getchar()) != EOF) {
  52.  
  53. if (c == '\n') {
  54. if (r == 0) {
  55. breaker = 0;
  56.  
  57. }
  58. break;
  59. } else {words[b].letters[r] = c;r++; }
  60.  
  61. }
  62.  
  63. r = 0;
  64. b++;
  65. }
  66. // printf("%d",b-1);
  67. //print the grid
  68. // printgrid(grid[MAXGRIDCOLS][MAXGRIDROWS], numCols, numRows,
  69. // *words[MAXNUMWORDS][MAXWORDLEN]);
  70.  
  71. for(i=0; i<b-1; i++){
  72. printf("%s\n", words[i].letters);
  73. }
  74. system("pause");
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement