fork download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int r,c,t,g,a;
  9. bool i;
  10. int grid[9][9];
  11. int rand(int);
  12. int check(void);
  13. void disp(void);
  14.  
  15. int main() {
  16. srand(time(NULL));
  17. cout << "\n\n\n\n\n\n\n\n\n\nGenerating puzzle...";
  18. r = 0;
  19. while (r <= 8) {
  20. g = 0;
  21. c = 0;
  22. while (c <= 8) {
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. disp();
  30. return 0;
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. int rand(void) {
  41. return rand() % 9;
  42. }
  43.  
  44. void disp(void) {
  45. int n,m;
  46. for (n=0; n<=8; n++){
  47. cout << "\n";
  48. for (m=0; m<=8; m++) {
  49. cout << grid[n][m] << " ";
  50. }
  51. }
  52. return 0
  53. }
  54.  
  55. int check(void) {
  56. int n,m,p,z;
  57. i = 0;
  58. //Horizontal check
  59. n = r;
  60. for (m=0; m<=8; m++) {
  61. if (grid[n][m] == t)
  62. i = 1;
  63. }
  64. if (i)
  65. return 0;
  66.  
  67. //Vertical check
  68. m = c;
  69. for (n=0; n<=8; n++) {
  70. if (grid[n][m] == t)
  71. i = 1;
  72. }
  73. if (i)
  74. return 0;
  75. // Square check
  76. if (r <= 2)
  77. n = 0;
  78. if (r >= 3 and r <= 5)
  79. n = 3;
  80. if (r >= 6)
  81. n = 6;
  82. if (c <= 2)
  83. m = 0;
  84. if (c >= 3 and c <= 5)
  85. m = 3;
  86. if (c >= 6)
  87. m = 6;
  88. p = m + 3;
  89.  
  90. for (z = 0; z <= 8; z++) {
  91. if (grid[n][m]== t)
  92. i = 1;
  93. m++;
  94. if (m == p) {
  95. m = m-3;
  96. n++;
  97. }
  98. }
  99. return 0
  100. }
Compilation error #stdin compilation error #stdout 0s 3140KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:40:16: error: a function-definition is not allowed here before '{' token
 int rand(void) { 
                ^
prog.cpp:44:17: error: a function-definition is not allowed here before '{' token
 void disp(void) { 
                 ^
prog.cpp:100:16: error: expected '}' at end of input
                } 
                ^
prog.cpp:100:16: error: expected '}' at end of input
stdout
Standard output is empty