Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define LOOPS 5000
- main() {
- new tick = tickcount();
- for(new i;i < LOOPS;i++){
- CheckNumberAndLetter("MlodyMaKota");
- CheckNumberAndLetter("696969");
- CheckNumberAndLetter("MlodyMaKota696969");
- }
- printf("time -> %d ms", (tickcount()-tick));
- tick = tickcount();
- for(new i;i<LOOPS;i++){
- CheckNumberAndLetter_V2("MlodyMaKota");
- CheckNumberAndLetter_V2("696969");
- CheckNumberAndLetter_V2("MlodyMaKota696969");
- }
- printf("time -> %d ms", (tickcount()-tick));
- }
- stock CheckNumberAndLetter(str[]) // By Mlody954
- {
- new l, bool:z[2];
- for(new x, l2 = strlen(str); x != l2; x++)
- {
- if((str[x] >= 'a' && str[x] <= 'z' || str[x] >= 'A' && str[x] <= 'Z') && !z[0])
- {
- l ++;
- z[0] = true;
- }
- if((str[x] >= '0' && str[x] <= '9') && !z[1])
- {
- l ++;
- z[1] = true;
- }
- if(l == 2) break;
- }
- if(l != 2) return false;
- else return true;
- }
- stock CheckNumberAndLetter_V2(const str[])
- {
- static
- bool:z[2 char],
- i = 0;
- while(EOS != str[i])
- {
- switch(str[i]) {
- case 'a'..'z', 'A'..'Z': {
- z{0} = true;
- }
- case '0'..'9': {
- z{1} = true;
- }
- }
- if(z{0} && z{1}) return true;
- ++i;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement