fork download
  1.  
  2. #include <stdio.h>
  3.  
  4. const int NUM_GUESSES = 7;
  5. const char SECRET[] = "hi";
  6.  
  7. #define F 0
  8. #define T 1
  9.  
  10. const int asdf[3][256] =
  11. {
  12. {
  13. F, 0, 0, 0, 0, 0, 0, F,
  14. 0, F, 0, 0, 0, 0, F, 0,
  15. 0, 0, F, 0, 0, F, 0, 0,
  16. 0, 0, 0, F, F, 0, 0, 0,
  17. 0, 0, 0, F, F, 0, 0, 0,
  18. 0, 0, F, 0, 0, F, 0, 0,
  19. 0, F, 0, 0, 0, 0, F, 0,
  20. F, 0, 0, 0, 0, 0, 0, F,
  21. 0, F, 0, 0, 0, 0, F, 0,
  22. 0, 0, F, 0, 0, F, 0, 0,
  23. 0, 0, 0, F, F, 0, 0, 0,
  24. 0, 0, 0, F, F, 0, 0, 0,
  25. 0, 0, F, 0, 0, F, 0, 0,
  26. 1, T, 0, 0, 0, 0, F, 0,
  27. F, 0, 0, 0, 0, 0, 0, F,
  28. 0, F, 0, 0, 0, 0, F, 0,
  29. 0, 0, F, 0, 0, F, 0, 0,
  30. 0, 0, 0, F, F, 0, 0, 0,
  31. 0, 0, 0, F, F, 0, 0, 0,
  32. 0, 0, F, 0, 0, F, 0, 0,
  33. 0, F, 0, 0, 0, 0, F, 0,
  34. F, 0, 0, 0, 0, 0, 0, F,
  35. 0, F, 0, 0, 0, 0, F, 0,
  36. 0, 0, F, 0, 0, F, 0, 0,
  37. 0, 0, 0, F, F, 0, 0, 0,
  38. 0, 0, 0, F, F, 0, 0, 0,
  39. 0, 0, F, 0, 0, F, 0, 0,
  40. 0, F, 0, 0, 0, 0, F, 0,
  41. F, 0, 0, 0, 0, 0, 0, F,
  42. 0, F, 0, 0, 0, 0, F, 0,
  43. 0, 0, F, 0, 0, F, 0, 0,
  44. 0, 0, 0, F, F, 0, 0, 0
  45. },
  46. {
  47. 0, F, 0, F, F, 0, F, 0,
  48. 0, F, 0, F, F, 0, F, 0,
  49. 0, F, 0, F, F, 0, F, 0,
  50. 0, F, 0, F, F, 0, F, 0,
  51. 0, F, 0, F, F, 0, F, 0,
  52. 0, F, 0, F, F, 0, F, 0,
  53. 0, F, 0, F, F, 0, F, 0,
  54. 0, F, 0, F, F, 0, F, 0,
  55. 0, 0, F, 0, 0, F, 0, 0,
  56. 0, 0, F, 0, 0, F, 0, 0,
  57. 0, 0, F, 0, 0, F, 0, 0,
  58. 0, 0, F, 0, 0, F, 0, 0,
  59. 0, 0, F, 0, 0, F, 0, 0,
  60. 0, 1, F, 0, 0, F, 0, 0,
  61. 0, 0, F, 0, 0, F, 0, 0,
  62. 0, 0, F, 0, 0, F, 0, 0,
  63. 0, 0, 0, F, F, 0, 0, 0,
  64. 0, 0, 0, F, F, 0, 0, 0,
  65. 0, 0, 0, F, F, 0, 0, 0,
  66. 0, 0, 0, F, F, 0, 0, 0,
  67. 0, 0, 0, F, F, 0, 0, 0,
  68. 0, 0, 0, F, F, 0, 0, 0,
  69. 0, 0, 0, F, F, 0, 0, 0,
  70. 0, 0, 0, F, F, 0, 0, 0,
  71. 0, 0, F, 0, 0, F, 0, 0,
  72. 0, 0, F, 0, 0, F, 0, 0,
  73. 0, 0, F, 0, 0, F, 0, 0,
  74. 0, 0, F, 0, 0, F, 0, 0,
  75. 0, 0, F, 0, 0, F, 0, 0,
  76. 0, 0, F, 0, 0, F, 0, 0,
  77. 0, 0, F, 0, 0, F, 0, 0,
  78. 0, 0, F, 0, 0, F, 0, 0
  79. },
  80. {
  81. F, 0, F, 0, F, 0, F, 0,
  82. 0, F, 0, F, 0, F, 0, F,
  83. 0, 0, F, 0, F, 0, F, 0,
  84. 0, 0, 0, F, 0, F, 0, F,
  85. F, 0, 0, 0, F, 0, F, 0,
  86. 0, F, 0, 0, 0, F, 0, F,
  87. F, 0, F, 0, 0, 0, F, 0,
  88. 0, F, 0, F, 0, 0, 0, F,
  89. F, 0, F, 0, F, 0, 0, 0,
  90. 0, F, 0, F, 0, F, 0, 0,
  91. F, 0, F, 0, F, 0, F, 0,
  92. 0, F, 0, F, 0, F, 0, F,
  93. 0, 0, F, 0, F, 0, F, 0,
  94. 1, 0, 0, F, 0, F, 0, F,
  95. F, 0, 0, 0, F, 0, F, 0,
  96. 0, F, 0, 0, 0, F, 0, F,
  97. F, 0, F, 0, 0, 0, F, 0,
  98. 0, F, 0, F, 0, 0, 0, F,
  99. F, 0, F, 0, F, 0, 0, 0,
  100. 0, F, 0, F, 0, F, 0, 0,
  101. F, 0, F, 0, F, 0, F, 0,
  102. 0, F, 0, F, 0, F, 0, F,
  103. 0, 0, F, 0, F, 0, F, 0,
  104. 0, 0, 0, F, 0, F, 0, F,
  105. F, 0, 0, 0, F, 0, F, 0,
  106. 0, F, 0, 0, 0, F, 0, F,
  107. F, 0, F, 0, 0, 0, F, 0,
  108. 0, F, 0, F, 0, 0, 0, F,
  109. F, 0, F, 0, F, 0, 0, 0,
  110. 0, F, 0, F, 0, F, 0, 0,
  111. F, 0, F, 0, F, 0, F, 0,
  112. 0, F, 0, F, 0, F, 0, F
  113. }
  114. };
  115.  
  116. int main()
  117. {
  118. char answer[] = "__";
  119. unsigned int hehehe = 0;
  120.  
  121. for (int i = 0; i < NUM_GUESSES; ++i)
  122. {
  123. printf("Enter a letter. %s\n", answer);
  124. char guess = getchar();
  125.  
  126. if(asdf[hehehe][guess])
  127. {
  128. int efef = (guess - SECRET[0]);
  129. answer[efef] = SECRET[efef];
  130. hehehe |= (1 << efef);
  131. }
  132. else
  133. {
  134. printf("Letter not found, try again\n");
  135. }
  136.  
  137. if (hehehe == 3)
  138. {
  139. printf("You win\n");
  140. break;
  141. }
  142. }
  143.  
  144. printf("The word was %s\n", SECRET);
  145. return 0;
  146. }
  147.  
Success #stdin #stdout 0s 2176KB
stdin
e
g
h
j
k
i
stdout
Enter a letter. __
Letter not found, try again
Enter a letter. __
Letter not found, try again
Enter a letter. __
Enter a letter. h_
Letter not found, try again
Enter a letter. h_
Letter not found, try again
Enter a letter. h_
You win
The word was hi