Advertisement
Lauda

Untitled

Jun 7th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. // Generisanje slucajnog slova (CPU mode)
  2. int randomSlovo()
  3. {
  4. char slova[22]  = "abcdefghijklmnoprstuvz";
  5. /*
  6. char used[11]   = {"x"};
  7. char rndSlovo;
  8.  
  9. int i, j;
  10. bool ok;
  11.  
  12. for (i = 0; i <= 10; i++)
  13. {
  14.     do
  15.     {
  16.         ok = true;
  17.         rndSlovo = slova[rand() % (22)];
  18.         for (j = 0; j <= 10; j++)
  19.         {
  20.             if (used[j] != '\0')
  21.             {
  22.                 if (rndSlovo == used[j])
  23.                     ok = false;
  24.             }
  25.             else
  26.             {
  27.                 ok = false;
  28.             }
  29.         }
  30.     }
  31.  
  32.         while (!ok);
  33.  
  34.     used[i] = rndSlovo;
  35.  
  36.     return used[i];
  37. }
  38.  
  39. */
  40.  
  41. srand(time(NULL));
  42.     return slova[rand() % (22)];
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement