函数

/*squeeze函数:从字符串s中删除字符c*/
void squeeze(char s[], int c)
{
 int i, j;
 for(i = j = 0;s[i] != '\0';i++)
  if(s[i] != c)
   s[j++] = s[i];
 s[j] = '\0'; 
}

/*strcat函数:将字符串t连接到字符串s的尾部;s必须有足够大的空间*/
void strcat(char s[], char t[])
{
 int i, j;
 i=j=0;
 while(s[i] != '\0')
  i++;
 while((s[i++] = t[j++]) != '\0')
  ;
}

/*bitcount函数:统计x中值为1的二进制位数*/
int bitcount(unsigned x)
{
 int b;
 for(b = 0;x != 0;x >>= 1)
  if(x & 01)
   b++;
 return b; 
}
 
 
posted @ 2019-11-13 15:54  烟火流沙  阅读(96)  评论(0编辑  收藏  举报