Advertisement
Guest User

Untitled

a guest
Aug 28th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.20 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define LOOPS 5000
  4.  
  5. main() {
  6.     new tick = tickcount();
  7.     for(new i;i < LOOPS;i++){
  8.         CheckNumberAndLetter("MlodyMaKota");
  9.         CheckNumberAndLetter("696969");
  10.         CheckNumberAndLetter("MlodyMaKota696969");
  11.     }
  12.     printf("time -> %d ms", (tickcount()-tick));
  13.     tick = tickcount();
  14.     for(new i;i<LOOPS;i++){
  15.         CheckNumberAndLetter_V2("MlodyMaKota");
  16.         CheckNumberAndLetter_V2("696969");
  17.         CheckNumberAndLetter_V2("MlodyMaKota696969");
  18.     }
  19.     printf("time -> %d ms", (tickcount()-tick));
  20. }
  21.  
  22. stock CheckNumberAndLetter(str[]) // By Mlody954
  23. {
  24.     new l, bool:z[2];
  25.     for(new x, l2 = strlen(str); x != l2; x++)
  26.     {
  27.         if((str[x] >= 'a' && str[x] <= 'z' || str[x] >= 'A' && str[x] <= 'Z') && !z[0])
  28.         {
  29.             l ++;
  30.             z[0] = true;
  31.         }
  32.  
  33.         if((str[x] >= '0' && str[x] <= '9') && !z[1])
  34.         {
  35.             l ++;
  36.             z[1] = true;
  37.         }
  38.  
  39.         if(l == 2) break;
  40.     }
  41.  
  42.     if(l != 2) return false;
  43.     else return true;
  44. }
  45.  
  46. stock CheckNumberAndLetter_V2(const str[])
  47. {
  48.     static
  49. bool:z[2 char],
  50.     i = 0;
  51.    
  52.     while(EOS != str[i])
  53.     {
  54.         switch(str[i]) {
  55.         case 'a'..'z', 'A'..'Z': {
  56.                 z{0} = true;
  57.             }
  58.         case '0'..'9': {
  59.                 z{1} = true;
  60.             }
  61.         }
  62.        
  63.         if(z{0} && z{1}) return true;
  64.         ++i;
  65.     }
  66.     return false;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement