Skip to content

Instantly share code, notes, and snippets.

@Bayonetta
Created November 3, 2015 02:49
Show Gist options
  • Save Bayonetta/ef7aa33917a55fe01bc2 to your computer and use it in GitHub Desktop.
Save Bayonetta/ef7aa33917a55fe01bc2 to your computer and use it in GitHub Desktop.
Sina Count Word Method
- (int)sinaCountWord:(NSString*)s
{
int i,n=[s length],l=0,a=0,b=0;
unichar c;
for(i=0;i<n;i++){
c=[s characterAtIndex:i];
if(isblank(c)){
b++;
}else if(isascii(c)){
a++;
}else{
l++;
}
}
if(a==0 && l==0) return 0;
return l+(int)ceilf((float)(a+b)/2.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment